md5-lib A high-performance C++17 library for calculating MD5 hashes
Loading...
Searching...
No Matches
md5_lib Namespace Reference

Functions

std::string CalculateMD5 (std::istream &stream)
 Calculates the MD5 hash of a data stream.
 
std::string CalculateMD5 (const unsigned char *data, std::size_t size)
 Calculates the MD5 hash of a contiguous block of memory.
 

Function Documentation

◆ CalculateMD5() [1/2]

std::string md5_lib::CalculateMD5 ( const unsigned char *  data,
std::size_t  size 
)

Calculates the MD5 hash of a contiguous block of memory.

A convenience overload for hashing data that is already in memory, such as a std::string or std::vector's data.

Parameters
dataA non-null pointer to the beginning of the data block. The type is const unsigned char* as it is the conventional type in C++ for representing raw, untyped byte data.
sizeThe size of the data block in bytes.
Returns
A 32-character lowercase hexadecimal string representing the MD5 hash.

◆ CalculateMD5() [2/2]

std::string md5_lib::CalculateMD5 ( std::istream &  stream)

Calculates the MD5 hash of a data stream.

Reads the input stream in chunks. The stream's state will be modified by the read operations.

Parameters
streamThe input stream to hash. The stream will be read until EOF.
Returns
A 32-character lowercase hexadecimal string representing the MD5 hash.
Exceptions
std::ios_base::failureon stream reading errors if the stream's exception mask is set to throw on badbit.