- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Classes | Public Member Functions | List of all members
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. More...
| 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. More...
void | close ()
| Called after the last add(). More...
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 )
{
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 238 of file md5.h.

## Constructor & Destructor Documentation

md5::digest_stream::digest_stream | ( |  | ) |

Default constructor.

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

## Member Function Documentation

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

Adds more message data.

Definition at line 392 of file md5.cpp.

void md5::digest_stream::close | ( |  | ) |

Called after the last add().

Definition at line 405 of file md5.cpp.

References md5::block::end().

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.

References md5::digest_stream::state_type::d, md5::digest_stream::state_type::n, and md5::digest_stream::state_type::s.

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

- md5.h
- md5.cpp