Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

ArMD5Calculator Class Reference

#include <ArMD5Calculator.h>

List of all members.


Detailed Description

Calculates the MD5 checksum when reading or writing a text file using ArFunctors.

ArMD5Calculator is a small helper class used to calculate MD5 checksums on text files. It contains a static method that will calculate the checksum of a given file, independently performing all I/O.

The calculator also contains a functor that can be used to calculate a checksum interactively. For example, it can accumulate the checksum while a file is being written using a writeToFunctor method. If the optional second functor is specified, then it will be invoked after the checksum functor.


Public Types

enum  { DIGEST_LENGTH = 16, DISPLAY_LENGTH = (DIGEST_LENGTH * 2) + 1 }

Public Member Functions

void append (const char *str)
 Calculates the checksum for the given text line, and accumulates the results.
 ArMD5Calculator (ArFunctor1< const char * > *secondFunctor=NULL)
 Creates a new calculator, with an optional functor.
unsigned char * getDigest ()
 Returns a pointer to the internal buffer that accumulates the checksum results.
ArFunctor1< const char * > * getFunctor ()
 Returns the internal functor used to calculate the checksum.
ArFunctor1< const char * > * getSecondFunctor ()
 Returns the optional secondary functor to be called on each text line.
void reset ()
 Resets the calculator so that a new checksum can be calculated.
void setSecondFunctor (ArFunctor1< const char * > *secondFunctor)
 Sets the optional secondary functor to be called on each text line.
 ~ArMD5Calculator ()
 Destructor.

Static Public Member Functions

static bool calculateChecksum (const char *fileName, unsigned char *md5DigestBuffer, size_t md5DigestBufferLen)
 Calculates the checksum for the specified file.
static void toDisplay (const unsigned char *digestBuf, size_t digestLength, char *displayBuf, size_t displayLength)
 Converts the given checksum buffer to a displayable text string.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
DIGEST_LENGTH  Number of bytes in the checksum buffer.
DISPLAY_LENGTH  Number of characters needed to display the checksum.


Constructor & Destructor Documentation

ArMD5Calculator::ArMD5Calculator ArFunctor1< const char * > *  secondFunctor = NULL  ) 
 

Creates a new calculator, with an optional functor.

Parameters:
secondFunctor the optional functor to be invoked on the current text string after its checksum has been calculated


Member Function Documentation

bool ArMD5Calculator::calculateChecksum const char *  fileName,
unsigned char *  md5DigestBuffer,
size_t  md5DigestBufferLen
[static]
 

Calculates the checksum for the specified file.

Parameters:
fileName the name of the file of which to calculate the checksum
md5DigestBuffer a pointer to the output buffer in which to store the calculated checksum
md5DigestBufferLen the length of the md5DigestBuffer; should be DIGEST_LENGTH
Returns:
bool true if the file was successfully opened and the checksum calculated; false, otherwise

ArFunctor1< const char * > * ArMD5Calculator::getFunctor  ) 
 

Returns the internal functor used to calculate the checksum.

If the calculator is being used interactively with writeToFunctor, then this is the functor to use. It calls append on each text line which accumulates the checksum and calls the second functor if necessary.

void ArMD5Calculator::toDisplay const unsigned char *  digestBuf,
size_t  digestLength,
char *  displayBuf,
size_t  displayLength
[static]
 

Converts the given checksum buffer to a displayable text string.

Parameters:
digestBuf a pointer to the byte array that contains the checksum
digestLength the length of the disgestBuf; should be DIGEST_LENGTH
displayBuf a pointer to the output text buffer that will contain the displayable text string
displayLength the length of the displayBuf; should be at least DISPLAY_LENGTH


The documentation for this class was generated from the following files:
Generated on Thu Jan 7 10:34:42 2010 for Aria by  doxygen 1.4.2