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>

List of all members.

Public Member Functions

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

Classes

struct  state_type
 Holds the md5 algorithm state. Used by md5::digest. 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 76 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 57 of file md5.cpp.

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

md5::digest::digest ( state_type  d  )  [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

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.

References result.

Referenced by md5::format::rfc(), and md5::digest_stream::state().

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

Adds a 64-byte block of the message.

Definition at line 68 of file md5.cpp.

Referenced by md5::digest_stream::add(), and md5::digest_stream::close().


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

Generated on Fri Apr 18 15:56:14 2008 for E-MailRelay by  doxygen 1.5.5