CMS 3D CMS Logo

Digest.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_Digest_h
2 #define FWCore_Utilities_Digest_h
3 
4 #include "md5.h"
5 
6 #include <iosfwd>
7 #include <string>
8 
9 namespace cms {
10 
11  struct MD5Result {
12  // The default-constructed MD5Result is invalid; all others are
13  // valid. The MD5 digest of the empty string is the value of the
14  // default-constructed MD5Result.
15  MD5Result();
16 
17  // This is the MD5 digest.
18  unsigned char bytes[16];
19 
20  // Convert the digest to a printable string (the 'hexdigest')
21  std::string toString() const;
22 
23  // The MD5 digest (not hexdigest) in string form
24  // 'std::basic_string<char>', rather than
25  // 'unsigned char [16]'
26  std::string compactForm() const;
27 
28  // Set our data from the given hexdigest string.
29  void fromHexifiedString(std::string const& s);
30 
31  bool isValid() const;
32  };
33 
34  bool operator==(MD5Result const& a, MD5Result const& b);
35  bool operator<(MD5Result const& a, MD5Result const& b);
36 
37  inline bool operator!=(MD5Result const& a, MD5Result const& b) { return !(a == b); }
38 
39  inline std::ostream& operator<<(std::ostream& os, MD5Result const& r) {
40  os << r.toString();
41  return os;
42  }
43 
44  // Digest creates an MD5 digest of the given string. The digest can
45  // be updated by using 'append'.
46  class Digest {
47  public:
48  Digest();
49  explicit Digest(std::string const& s);
50 
51  void append(std::string const& s);
52  void append(const char* data, size_t size);
53 
54  MD5Result digest();
55 
56  private:
57  md5_state_t state_;
58  };
59 } // namespace cms
60 
61 #endif
cms::Digest::append
void append(std::string const &s)
Definition: Digest.cc:161
cms::MD5Result::isValid
bool isValid() const
Definition: Digest.cc:139
cms::Digest::digest
MD5Result digest()
Definition: Digest.cc:171
cms::MD5Result::fromHexifiedString
void fromHexifiedString(std::string const &s)
Definition: Digest.cc:117
cms::MD5Result::bytes
unsigned char bytes[16]
Definition: Digest.h:18
alignCSCRings.s
s
Definition: alignCSCRings.py:92
cms::Digest
Definition: Digest.h:46
cms::operator==
bool operator==(MD5Result const &a, MD5Result const &b)
Definition: Digest.cc:141
b
double b
Definition: hdecay.h:118
cms::Digest::state_
md5_state_t state_
Definition: Digest.h:57
cms::MD5Result
Definition: Digest.h:11
a
double a
Definition: hdecay.h:119
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
alignCSCRings.r
r
Definition: alignCSCRings.py:93
cms::operator<
bool operator<(MD5Result const &a, MD5Result const &b)
Definition: Digest.cc:145
cms::operator!=
bool operator!=(MD5Result const &a, MD5Result const &b)
Definition: Digest.h:37
cms::Digest::Digest
Digest()
Definition: Digest.cc:154
cms::MD5Result::compactForm
std::string compactForm() const
Definition: Digest.cc:109
cms::MD5Result::MD5Result
MD5Result()
Definition: Digest.cc:75
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cms::MD5Result::toString
std::string toString() const
Definition: Digest.cc:95
cms::operator<<
std::ostream & operator<<(std::ostream &os, MD5Result const &r)
Definition: Digest.h:39
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443