ProteoWizard
Main Page
Namespaces
Classes
Files
File List
File Members
pwiz
utility
misc
SHA1Calculator.hpp
Go to the documentation of this file.
1
//
2
// $Id: SHA1Calculator.hpp 1616 2009-12-11 21:26:54Z chambm $
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
27
#include "
pwiz/utility/misc/Export.hpp
"
28
#include "boost/shared_ptr.hpp"
29
#include <string>
30
#include <iostream>
31
32
33
namespace
pwiz {
34
namespace
util {
35
36
37
class
PWIZ_API_DECL
SHA1Calculator
38
{
39
public
:
40
41
SHA1Calculator
();
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_
;
78
SHA1Calculator
(
const
SHA1Calculator
&);
79
SHA1Calculator
& operator=(
const
SHA1Calculator
&);
80
};
81
82
83
}
// namespace util
84
}
// namespace pwiz
85
86
87
#endif // _SHA1CALCULATOR_HPP_
88
Generated on Mon Nov 26 2012 18:05:49 for ProteoWizard by
1.8.1.1