LibPkg
Public Types | Public Member Functions | List of all members
pkg::md5 Class Reference

A class for producing MD5 message digests. More...

#include <md5.h>

Public Types

typedef unsigned long uint32
 A type to represent an unsigned 32-bit integer. More...
 
typedef unsigned long long uint64
 A type to represent an unsigned 64-bit integer. More...
 

Public Member Functions

 md5 ()
 Construct MD5 object. More...
 
void operator() (const void *data, size_t length)
 Process data in memory. More...
 
void operator() (std::istream &in)
 Process data from stream. More...
 
void operator() ()
 Flush buffer. More...
 
uint32 operator[] (unsigned int index)
 Read word from message digest. More...
 
 operator string ()
 Convert message digest to hexadecimal string. More...
 

Detailed Description

A class for producing MD5 message digests.

MD5 is a message digest algorithm published by Ron Rivest in 1992. It takes a message of arbitrary length and produces a 128-bit digest. A specification for the algorithm can be found in RFC 1321 and this implementation follows that specification very closely. It is not, however, derived from the reference implementation given in appendix A

Member Typedef Documentation

typedef unsigned long pkg::md5::uint32

A type to represent an unsigned 32-bit integer.

typedef unsigned long long pkg::md5::uint64

A type to represent an unsigned 64-bit integer.

Constructor & Destructor Documentation

pkg::md5::md5 ( )

Construct MD5 object.

Member Function Documentation

void pkg::md5::operator() ( const void *  data,
size_t  length 
)

Process data in memory.

The specified number of bytes are transferred from memory to the input buffer. Any complete blocks of 16 bytes are incorporated into the message digest state.

Parameters
dataa pointer to the data
lengththe length of the data in bytes
void pkg::md5::operator() ( std::istream &  in)

Process data from stream.

Bytes are transferred from the stream to the input buffer until the end of file is reached. Any complete blocks of 16 bytes are incorporated into the message digest state.

Parameters
inthe input stream from which the data is to be read

References operator()().

void pkg::md5::operator() ( )

Flush buffer.

The final value of the message digest is calculated by processing any bytes still remaining in the buffer, followed by between 1 and 16 bytes of padding,

Referenced by operator()().

uint32 pkg::md5::operator[] ( unsigned int  index)
inline

Read word from message digest.

The digest is presented as an array of four 32-bit words. Although this function may be called at any time, the result is only meaningful after the buffer has been flushed. Its effect is undefined if the index falls outside the range 0 to 3 inclusive.

Parameters
indexthe index of the word to be read
Returns
a word from the message digest
pkg::md5::operator string ( )

Convert message digest to hexadecimal string.

The digest is presented low-order byte, high-order nybble first. Although this function may be called at any time, the result is only meaningful after the buffer has been flushed.

Returns
the message digest, as a hexadecimal string

The documentation for this class was generated from the following files:

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)