/* */ #ifndef _D_MESSAGE_DIGEST_HELPER_H_ #define _D_MESSAGE_DIGEST_HELPER_H_ #include "common.h" #include "BinaryStream.h" class MessageDigestHelper { public: /** * Returns message digest in hexadecimal notation. * Digest algorithm is specified by algo. */ static string digest(const string& algo, const BinaryStreamHandle& bs, int64_t offset, int64_t length); /** * Calculates message digest of file denoted by filename. */ static string digest(const string& algo, const string& filename); static string digest(const string& algo, const void* data, int32_t length); static string digestString(const string& algo, const string& data) { return digest(algo, data.c_str(), data.size()); } /** * Stores *raw* message digest into md. * Throws exception when mdLength is less than the size of message digest. */ static void digest(unsigned char* md, int32_t mdLength, const string& algo, const void* data, int32_t length); }; #endif // _D_MESSAGE_DIGEST_HELPER_H_