23 #ifdef SERIALBOX_HAS_OPENSSL 24 #include <openssl/md5.h> 31 std::string
MD5::hash(
const void* data,
int length) {
34 #ifdef SERIALBOX_HAS_OPENSSL 36 unsigned char digest[MD5_DIGEST_LENGTH];
37 ::MD5((
unsigned char*)data, length, digest);
39 std::ostringstream ss;
40 ss << std::hex << std::setfill(
'0') << std::setw(2) << std::uppercase;
41 std::copy(digest, digest + MD5_DIGEST_LENGTH, std::ostream_iterator<int>(ss));
45 throw Exception(
"MD5 hash is only available with OpenSSL support");
virtual std::string hash(const void *data, int length) override
Compute 128 bit hash using MD5.
Namespace of the serialbox library.
static const char * Name
Identifier of the hash.
Implementation of MD5 cryptographic hash algorithm.
Exception class which stores a human-readable error description.