CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
unsigned char bytes[16]
Definition: Digest.h:18
void fromHexifiedString(std::string const &s)
Definition: Digest.cc:117
MD5Result digest()
Definition: Digest.cc:171
bool operator<(MD5Result const &a, MD5Result const &b)
Definition: Digest.cc:145
std::string compactForm() const
Definition: Digest.cc:109
bool isValid() const
Definition: Digest.cc:139
bool operator==(MD5Result const &a, MD5Result const &b)
Definition: Digest.cc:141
md5_state_t state_
Definition: Digest.h:57
std::string toString() const
Definition: Digest.cc:95
double b
Definition: hdecay.h:118
bool operator!=(MD5Result const &a, MD5Result const &b)
Definition: Digest.h:37
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
double a
Definition: hdecay.h:119
std::ostream & operator<<(std::ostream &os, MD5Result const &r)
Definition: Digest.h:39
tuple size
Write out results.
void append(std::string const &s)
Definition: Digest.cc:161