11 #include "StringUtils.h" 18 #include <openssl/evp.h> 58 void Update(std::string
const& data);
64 void Update(
void const* data, std::size_t size);
87 static std::string
Calculate(Type type, std::string
const& data);
91 static std::string
Calculate(Type type,
void const* data, std::size_t size);
96 void operator()(EVP_MD_CTX* context);
99 bool m_finalized{
false};
100 std::unique_ptr<EVP_MD_CTX, MdCtxDeleter> m_context;
106 CDigest::Type type{CDigest::Type::INVALID};
111 TypedDigest(CDigest::Type type, std::string
const& value)
112 : type(type), value(value)
117 return (type == CDigest::Type::INVALID || value.empty());
123 if (left.type != right.type)
125 throw std::logic_error(
"Cannot compare digests of different type");
127 return StringUtils::EqualsNoCase(left.value, right.value);
132 return !(left == right);
135 std::ostream& operator<<(std::ostream& os,
TypedDigest const& digest);
void Update(std::string const &data)
Update digest with data.
Definition: Digest.cpp:109
static std::string Calculate(Type type, std::string const &data)
Calculate message digest.
Definition: Digest.cpp:154
CDigest(Type type)
Create a digest calculation object.
Definition: Digest.cpp:100
std::string FinalizeRaw()
Finalize and return the digest.
Definition: Digest.cpp:127
static std::string TypeToString(Type type)
Convert type enumeration value to lower-case string representation.
Definition: Digest.cpp:50
static Type TypeFromString(std::string const &type)
Convert digest type string representation to enumeration value.
Definition: Digest.cpp:69
std::string Finalize()
Finalize and return the digest.
Definition: Digest.cpp:149
Utility class for calculating message digests/hashes, currently using OpenSSL.
Definition: Digest.h:28
Definition: AudioDecoder.h:18