VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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>

Classes

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

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. More...
 
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. More...
 
state_type state () const
 Returns the current state. 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 )
{
while( in.good() )
{
std::string line ;
std::getline( in , line ) ;
d.add( line ) ;
}
d.close() ;
return md5::format::rfc( d ) ;
}

Definition at line 238 of file md5.h.

Constructor & Destructor Documentation

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 386 of file md5.cpp.

Member Function Documentation

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

Returns how many data bytes have been accumulated so far.

Definition at line 421 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 412 of file md5.cpp.


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