|
OpenM++ runtime library (libopenm)
|
#include <md5.h>
Public Types | |
| enum | { BlockSize = 512 / 8 , HashBytes = 16 } |
| split into 64 byte blocks (=> 512 bits), hash is 16 bytes long | |
Public Member Functions | |
| MD5 () | |
| same as reset() | |
| std::string | operator() (const void *data, size_t numBytes) |
| compute MD5 of a memory block | |
| std::string | operator() (const std::string &text) |
| compute MD5 of a string, excluding final zero | |
| void | add (const void *data, size_t numBytes) |
| add arbitrary number of bytes | |
| std::string | getHash () |
| return latest hash as 32 hex characters | |
| void | getHash (unsigned char buffer[HashBytes]) |
| return latest hash as bytes | |
| void | reset () |
| restart | |
compute MD5 hash
Usage: MD5 md5; std::string myHash = md5("Hello World"); // std::string std::string myHash2 = md5("How are you", 11); // arbitrary data, 11 bytes
or in a streaming fashion:
MD5 md5; while (more data available) md5.add(pointer to fresh data, number of new bytes); std::string myHash3 = md5.getHash();