CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Digest.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_Digest_h
2 #define FWCore_Utilities_Digest_h
3 
5 
6 #include <iosfwd>
7 #include <string>
8 
9 
10 namespace cms
11 {
12 
13  struct MD5Result
14  {
15  // The default-constructed MD5Result is invalid; all others are
16  // valid. The MD5 digest of the empty string is the value of the
17  // default-constructed MD5Result.
18  MD5Result();
19 
20  // This is the MD5 digest.
21  unsigned char bytes[16];
22 
23  // Convert the digest to a printable string (the 'hexdigest')
24  std::string toString() const;
25 
26  // The MD5 digest (not hexdigest) in string form
27  // 'std::basic_string<char>', rather than
28  // 'unsigned char [16]'
29  std::string compactForm() const;
30 
31  // Set our data from the given hexdigest string.
32  void fromHexifiedString(std::string const& s);
33 
34  bool isValid() const;
35  };
36 
37  bool operator==(MD5Result const& a, MD5Result const& b);
38  bool operator< (MD5Result const& a, MD5Result const& b);
39 
40  inline bool operator!=(MD5Result const& a, MD5Result const& b)
41  {
42  return !(a==b);
43  }
44 
45  inline
46  std::ostream& operator<< (std::ostream& os, MD5Result const& r)
47  {
48  os << r.toString();
49  return os;
50  }
51 
52  // Digest creates an MD5 digest of the given string. The digest can
53  // be updated by using 'append'.
54  class Digest
55  {
56  public:
57  Digest();
58  explicit Digest(std::string const& s);
59 
60  void append(std::string const& s);
61  void append(const char *data, size_t size);
62 
63  MD5Result digest() const;
64 
65  private:
67  };
68 }
69 
70 #endif
unsigned char bytes[16]
Definition: Digest.h:21
MD5Result digest() const
Definition: Digest.cc:194
void fromHexifiedString(std::string const &s)
Definition: Digest.cc:111
bool operator<(MD5Result const &a, MD5Result const &b)
Definition: Digest.cc:154
std::string compactForm() const
Definition: Digest.cc:102
bool isValid() const
Definition: Digest.cc:143
bool operator==(MD5Result const &a, MD5Result const &b)
Definition: Digest.cc:148
md5_state_t state_
Definition: Digest.h:66
std::string toString() const
Definition: Digest.cc:87
double b
Definition: hdecay.h:120
bool operator!=(MD5Result const &a, MD5Result const &b)
Definition: Digest.h:40
double a
Definition: hdecay.h:121
std::ostream & operator<<(std::ostream &os, MD5Result const &r)
Definition: Digest.h:46
tuple size
Write out results.
void append(std::string const &s)
Definition: Digest.cc:182