- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Classes | Public Member Functions | List of all members
md5::digest Class Reference

A class that calculates an md5 digest from one or more 64-byte blocks of data using the algorithm described by RFC 1321. More...

`#include <md5.h>`

## Classes
struct | state_type
| Holds the md5 algorithm state. Used by md5::digest. More...

## Public Member Functions
| digest ()
| Default constructor. More...
| digest (const string_type &s)
| Constuctor. More...
| digest (state_type)
| Constructor taking the result of an earlier call to state(). More...
state_type | state () const
| Returns the internal state. More...
void | add (const block &)
| Adds a 64-byte block of the message. More...

## Detailed Description

A class that calculates an md5 digest from one or more 64-byte blocks of data using the algorithm described by RFC 1321.

Digests are made up of four integers which can be formatted into more usable forms using the md5::format class.

A digest can be calculated in one go from an arbitrarily-sized block of data, or incrementally from a series of 64-byte blocks. The 64-byte blocks must be passed as md5::block objects.

In practice the requirement for 64-byte blocks of input data may be inconvenient, so the md5::digest_stream class is provided to allow calculation of digests from a stream of arbitrarily-sized data blocks.

std::string hash( const std::string & in )
{
md5::digest d( in ) ;
return md5::format::rfc( d ) ;
}

Definition at line 77 of file md5.h.

## Constructor & Destructor Documentation

md5::digest::digest | ( |  | ) |

Default constructor.

The message to be digested should be add()ed in 64-byte blocks.

Definition at line 35 of file md5.cpp.

md5::digest::digest | ( | const string_type & | s | ) |
| explicit

Constuctor.

Calculates a digest for the given message string. Do not use add() with this constructor.

Definition at line 62 of file md5.cpp.

References md5::block::blocks(), and md5::block::end().

md5::digest::digest | ( | state_type | d_in | ) |
| explicit

Constructor taking the result of an earlier call to state().

This allows calculation of a digest from a stream of 64-byte blocks to be suspended mid-stream and then resumed using a new digest object.

Definition at line 40 of file md5.cpp.

## Member Function Documentation

void md5::digest::add | ( | const block & | m | ) |

Adds a 64-byte block of the message.

Definition at line 73 of file md5.cpp.

md5::digest::state_type md5::digest::state | ( |  | ) | const

Returns the internal state.

Typically passed to the md5::format class.

Definition at line 48 of file md5.cpp.

Referenced by md5::format::rfc().

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

- md5.h
- md5.cpp