File indexing completed on 2024-11-25 02:29:37
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 <string_view>
0009 #include <array>
0010
0011 namespace cms {
0012
0013 struct MD5Result {
0014
0015
0016
0017 MD5Result();
0018
0019
0020 std::array<unsigned char, 16> bytes;
0021
0022
0023 std::string toString() const;
0024
0025
0026
0027
0028 std::string compactForm() const;
0029
0030
0031 void fromHexifiedString(std::string_view);
0032
0033 bool isValid() const;
0034 };
0035
0036 bool operator==(MD5Result const& a, MD5Result const& b);
0037 bool operator<(MD5Result const& a, MD5Result const& b);
0038
0039 inline bool operator!=(MD5Result const& a, MD5Result const& b) { return !(a == b); }
0040
0041 inline std::ostream& operator<<(std::ostream& os, MD5Result const& r) {
0042 os << r.toString();
0043 return os;
0044 }
0045
0046
0047
0048 class Digest {
0049 public:
0050 Digest();
0051 explicit Digest(std::string const& s);
0052 explicit Digest(std::string_view);
0053 explicit Digest(const char*);
0054
0055 void append(std::string const& s);
0056 void append(const char* data, size_t size);
0057 void append(std::string_view v);
0058
0059 MD5Result digest();
0060
0061 private:
0062 md5_state_t state_;
0063 };
0064 }
0065
0066 #endif