Slightly modified MD5 lib. Allows access to raw binary instead of hexadecimal ascii.

Embed: (wiki syntax)

« Back to documentation index

MD5 Class Reference

MD5 Class Reference

a small class for calculating MD5 hashes of strings or byte arrays it is not meant to be fast or secure More...

#include <md5.h>

Public Member Functions

 MD5 (const std::string &text)
 take string, hash it and finalize
void update (const unsigned char *buf, size_type length)
 add text to hash
void update (const char *buf, size_type length)
 add text to hash
MD5finalize ()
 calculate the final hash value
std::string hexdigest () const
const unsigned char * rawdigest () const

Detailed Description

a small class for calculating MD5 hashes of strings or byte arrays it is not meant to be fast or secure

usage: 1) feed it blocks of uchars with update() 2) finalize() 3) get hexdigest() string or MD5(std::string).hexdigest()

assumes that char is 8 bit and int is 32 bit

Definition at line 50 of file md5.h.


Constructor & Destructor Documentation

MD5 ( const std::string &  text )

take string, hash it and finalize

Parameters:
textthe string to hash

Definition at line 112 of file md5.c.


Member Function Documentation

MD5 & finalize (  )

calculate the final hash value

Definition at line 299 of file md5.c.

std::string hexdigest (  ) const
Returns:
the hash as hex string

Definition at line 336 of file md5.c.

const unsigned char* rawdigest (  ) const
Returns:
the hash as binary data, an array of 16 bytes.

Definition at line 87 of file md5.h.

void update ( const char *  buf,
size_type  length 
)

add text to hash

Parameters:
bufthe text to add to the hash
textlength
void update ( const unsigned char *  buf,
size_type  length 
)

add text to hash

Parameters:
bufthe text to add to the hash
textlength