/* */ #ifndef D_MESSAGE_DIGEST_HELPER_H #define D_MESSAGE_DIGEST_HELPER_H #include "common.h" #include #include "SharedHandle.h" namespace aria2 { class BinaryStream; class MessageDigest; namespace message_digest { /** * staticSHA1DigestInit(), staticSHA1DigestFree(), staticSHA1Digest() * use statically declared MessageDigest sha1Ctx_. */ /** * Initializes sha1Ctx_ */ void staticSHA1DigestInit(); /** * Frees allocated resources for sha1Ctx_ */ void staticSHA1DigestFree(); std::string staticSHA1Digest (const SharedHandle& bs, off_t offset, uint64_t length); /** * ctx must be initialized or reseted before calling this function. * Returns raw digest string, not hex digest */ std::string digest (const SharedHandle& ctx, const SharedHandle& bs, off_t offset, uint64_t length); /** * Stores *raw* message digest into md. * Throws exception when mdLength is less than the size of message digest. */ void digest (unsigned char* md, size_t mdLength, const SharedHandle& ctx, const void* data, size_t length); } // namespace message_digest } // namespace aria2 #endif // D_MESSAGE_DIGEST_HELPER_H