md5::digest_stream Class Reference

A class that calculates an md5 digest from a data stream using the algorithm described by RFC 1321. More...

#include <md5.h>

List of all members.

Public Member Functions

 digest_stream ()
 Default constructor.
 digest_stream (digest::state_type d, small_t n)
 Constructor taking state() allowing digest calculation to be suspended and resumed.
void add (const string_type &)
 Adds more message data.
void close ()
 Called after the last add().
small_t size () const
 Returns how many data bytes have been accumulated so far.
state_type state () const
 Returns the current state.

Classes

struct  state_type
 < Holds the state of an md5 digest stream. Used by md5::digest_stream. More...


Detailed Description

A class that calculates an md5 digest from a data stream using the algorithm described by RFC 1321.

The implementation is layered on top of the block-oriented md5::digest by adding an element of buffering. The buffering allows incremental calculation of an md5 digest without requiring either the complete input string or precise 64-byte blocks.

        std::string hash( std::istream & in )
        {
                md5::digest_stream d ;
                while( in.good() )
                {
                        std::string line ;
                        std::getline( in , line ) ;
                        d.add( line ) ;
                }
                d.close() ;
                return md5::format::rfc( d ) ;
        }

Definition at line 237 of file md5.h.


Constructor & Destructor Documentation

md5::digest_stream::digest_stream (  ) 

Default constructor.

Definition at line 376 of file md5.cpp.

md5::digest_stream::digest_stream ( digest::state_type  d,
small_t  n 
)

Constructor taking state() allowing digest calculation to be suspended and resumed.

The 'n' parameter must be a multiple of sixty-four (since "state_type::s" string is implicitly empty).

Definition at line 381 of file md5.cpp.


Member Function Documentation

void md5::digest_stream::add ( const string_type s  ) 

Adds more message data.

Definition at line 387 of file md5.cpp.

References md5::digest::add().

void md5::digest_stream::close (  ) 

Called after the last add().

Definition at line 400 of file md5.cpp.

References md5::digest::add(), and md5::block::end().

md5::small_t md5::digest_stream::size (  )  const

Returns how many data bytes have been accumulated so far.

Definition at line 416 of file md5.cpp.

md5::digest_stream::state_type md5::digest_stream::state (  )  const

Returns the current state.

Only useful after close().

Definition at line 407 of file md5.cpp.

References md5::digest_stream::state_type::d, md5::digest_stream::state_type::n, md5::digest_stream::state_type::s, and md5::digest::state().


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