Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
elm::checksum::MD5 Class Reference

#include <elm/checksum/MD5.h>

+ Inheritance diagram for elm::checksum::MD5:

Public Types

typedef unsigned char digest_t [16]
 

Public Member Functions

 MD5 (void)
 
virtual ~MD5 (void)
 
void digest (digest_t tab)
 
void print (io::Output &out)
 
void put (const void *buffer, t::uint32 length)
 
void put (const cstring &str)
 
void put (const string &str)
 
void put (io::InStream &in)
 
void put (io::InStream &in, int length)
 
MD5operator<< (const char *str)
 
MD5operator<< (const CString &str)
 
MD5operator<< (const String &str)
 
template<class T >
MD5operator<< (const T &value)
 
virtual int write (const char *buffer, int size)
 
virtual int flush (void)
 
virtual cstring lastErrorMessage (void)
 
- Public Member Functions inherited from elm::io::OutStream
virtual ~OutStream (void)
 
virtual int write (char byte)
 

Additional Inherited Members

- Static Public Attributes inherited from elm::io::OutStream
static OutStreamnull = _null
 

Detailed Description

Apply the MD5 algorithm (http://fr.wikipedia.org/wiki/MD5) to compute a checksum.

Data are checksummed calling any one of the put() methods (or using the overloaded operator <<). When all data has been checksummed, the checksum value is returned by digest().

Member Typedef Documentation

typedef unsigned char elm::checksum::MD5::digest_t[16]

Constructor & Destructor Documentation

elm::checksum::MD5::MD5 ( void  )

Build a new MD5 checksum builder.

elm::checksum::MD5::~MD5 ( void  )
virtual

Member Function Documentation

void elm::checksum::MD5::digest ( digest_t  tab)

Get the check as 512 bits byte array.

Parameters
tabDigest result.
int elm::checksum::MD5::flush ( void  )
virtual

Cause the current stream to dump its buffer to the medium.

Returns
0 for success, less than 0 for error.

Implements elm::io::OutStream.

cstring elm::checksum::MD5::lastErrorMessage ( void  )
virtual

Return a message for the last error.

Returns
Message of the last error.

Reimplemented from elm::io::OutStream.

MD5& elm::checksum::MD5::operator<< ( const char *  str)

References put().

MD5& elm::checksum::MD5::operator<< ( const CString str)

References put().

MD5& elm::checksum::MD5::operator<< ( const String str)

References put().

template<class T >
MD5& elm::checksum::MD5::operator<< ( const T &  value)

References put().

void elm::checksum::MD5::print ( io::Output out)

Print the MD5 digest as an hexadecimal value.

References elm::io::hex(), elm::io::pad(), elm::io::right(), and elm::io::width().

Referenced by elm::checksum::operator<<().

void elm::checksum::MD5::put ( const void *  block,
t::uint32  length 
)

Put a data block in the checksum.

Parameters
blockBlock address.
lengthBlock length.

References elm::min().

Referenced by operator<<(), put(), and write().

void elm::checksum::MD5::put ( const cstring str)

Put a C string in the checksum.

Parameters
strC string to put in.

References elm::CString::chars(), elm::CString::length(), and put().

void elm::checksum::MD5::put ( const string str)

Put a string in the checksum.

Parameters
strString to put in.

References elm::String::length(), and put().

void elm::checksum::MD5::put ( io::InStream in)

Put an input stream in the buffer. Read to the end of the stream.

Parameters
inInput stream to read.
Exceptions
io::IOExceptionIf there is an error during stream read.

References elm::io::InStream::read().

void elm::checksum::MD5::put ( io::InStream in,
int  length 
)

Put at most length bytes from the given stream to compute the MD5 checksum.

Parameters
inInput stream to read.
lengthMaximum number of bytes to read.
Exceptions
io::IOExceptionIf there is an error during stream read.

References elm::min(), and elm::io::InStream::read().

int elm::checksum::MD5::write ( const char *  buffer,
int  size 
)
virtual

This is the main method of an output stream: the given buffer is put on the stream.

Parameters
bufferByte buffer to write.
sizeSize of the byte buffer.
Returns
Number of transferred bytes or less than 0 for an error.

Implements elm::io::OutStream.

References put().

Member Data Documentation

t::uint32 elm::checksum::MD5::A
t::uint32 elm::checksum::MD5::B
t::uint32 elm::checksum::MD5::C
t::uint32 elm::checksum::MD5::D

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