/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
FWCore/Utilities/interface/Digest.h
66 строк
2 KB
Chris Jones
Digest::fromHexifiedString now uses a std::string_view
22 ноя 2024, 17:49
22 ноя 2024, 17:49
4fb8f1a
Код
Авторство
О чём код?
#ifndef FWCore_Utilities_Digest_h #define FWCore_Utilities_Digest_h #include "md5.h" #include <iosfwd> #include <string> #include <string_view> #include <array> namespace cms { struct MD5Result { // The default-constructed MD5Result is invalid; all others are // valid. The MD5 digest of the empty string is the value of the // default-constructed MD5Result. MD5Result(); // This is the MD5 digest. std::array<unsigned char, 16> bytes; // Convert the digest to a printable string (the 'hexdigest') std::string toString() const; // The MD5 digest (not hexdigest) in string form // 'std::basic_string<char>', rather than // 'unsigned char [16]' std::string compactForm() const; // Set our data from the given hexdigest string. void fromHexifiedString(std::string_view); bool isValid() const; }; bool operator==(MD5Result const& a, MD5Result const& b); bool operator<(MD5Result const& a, MD5Result const& b); inline bool operator!=(MD5Result const& a, MD5Result const& b) { return !(a == b); } inline std::ostream& operator<<(std::ostream& os, MD5Result const& r) { os << r.toString(); return os; } // Digest creates an MD5 digest of the given string. The digest can // be updated by using 'append'. class Digest { public: Digest(); explicit Digest(std::string const& s); explicit Digest(std::string_view); explicit Digest(const char*); void append(std::string const& s); void append(const char* data, size_t size); void append(std::string_view v); MD5Result digest(); private: md5_state_t state_; }; } // namespace cms #endif