File indexing completed on 2024-04-06 12:13:11
0001 #ifndef FWCore_Utilities_Digest_h
0002 #define FWCore_Utilities_Digest_h
0003
0004 #include "md5.h"
0005
0006 #include <iosfwd>
0007 #include <string>
0008 #include <array>
0009
0010 namespace cms {
0011
0012 struct MD5Result {
0013
0014
0015
0016 MD5Result();
0017
0018
0019 std::array<unsigned char, 16> bytes;
0020
0021
0022 std::string toString() const;
0023
0024
0025
0026
0027 std::string compactForm() const;
0028
0029
0030 void fromHexifiedString(std::string const& s);
0031
0032 bool isValid() const;
0033 };
0034
0035 bool operator==(MD5Result const& a, MD5Result const& b);
0036 bool operator<(MD5Result const& a, MD5Result const& b);
0037
0038 inline bool operator!=(MD5Result const& a, MD5Result const& b) { return !(a == b); }
0039
0040 inline std::ostream& operator<<(std::ostream& os, MD5Result const& r) {
0041 os << r.toString();
0042 return os;
0043 }
0044
0045
0046
0047 class Digest {
0048 public:
0049 Digest();
0050 explicit Digest(std::string const& s);
0051
0052 void append(std::string const& s);
0053 void append(const char* data, size_t size);
0054
0055 MD5Result digest();
0056
0057 private:
0058 md5_state_t state_;
0059 };
0060 }
0061
0062 #endif