ProteoWizard
SHA1Calculator.hpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Darren Kessner <darren@proteowizard.org>
6//
7// Copyright 2007 Spielberg Family Center for Applied Proteomics
8// Cedars-Sinai Medical Center, Los Angeles, California 90048
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21//
22
23
24#ifndef _SHA1CALCULATOR_HPP_
25#define _SHA1CALCULATOR_HPP_
26
28#include "boost/shared_ptr.hpp"
29#include <string>
30#include <iostream>
31
32
33namespace pwiz {
34namespace util {
35
36
38{
39 public:
40
42
43 /// resets hash
44 void reset();
45
46 /// update hash with buffer of bytes
47 void update(const unsigned char* buffer, size_t bufferSize);
48
49 /// update hash with buffer of bytes
50 void update(const std::string& buffer);
51
52 /// finish the hash
53 void close();
54
55 /// returns the current hash value
56 /// note: close() must be called first to retrieve final hash value
57 std::string hash() const;
58
59 /// returns projected final hash value as if close() were called first;
60 /// hash remains open and update() may be called afterwards
61 std::string hashProjected() const;
62
63 /// static function to calculate hash of a buffer
64 static std::string hash(const std::string& buffer);
65
66 /// static function to calculate hash of a buffer
67 static std::string hash(const unsigned char* buffer, size_t bufferSize);
68
69 /// static function to calculate hash of an input stream
70 static std::string hash(std::istream& is);
71
72 /// static function to calculate hash of a file
73 static std::string hashFile(const std::string& filename);
74
75 private:
76 class Impl;
77 boost::shared_ptr<Impl> impl_;
80};
81
82
83} // namespace util
84} // namespace pwiz
85
86
87#endif // _SHA1CALCULATOR_HPP_
88
#define PWIZ_API_DECL
Definition Export.hpp:32
SHA1Calculator & operator=(const SHA1Calculator &)
void close()
finish the hash
static std::string hash(const std::string &buffer)
static function to calculate hash of a buffer
void reset()
resets hash
static std::string hashFile(const std::string &filename)
static function to calculate hash of a file
SHA1Calculator(const SHA1Calculator &)
static std::string hash(std::istream &is)
static function to calculate hash of an input stream
boost::shared_ptr< Impl > impl_
std::string hashProjected() const
returns projected final hash value as if close() were called first; hash remains open and update() ma...
std::string hash() const
returns the current hash value note: close() must be called first to retrieve final hash value
void update(const unsigned char *buffer, size_t bufferSize)
update hash with buffer of bytes
static std::string hash(const unsigned char *buffer, size_t bufferSize)
static function to calculate hash of a buffer
void update(const std::string &buffer)
update hash with buffer of bytes