#include <ArMD5Calculator.h>
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. |
|
|
|
Creates a new calculator, with an optional functor.
|
|
Calculates the checksum for the specified file.
|
|
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. |
|
Converts the given checksum buffer to a displayable text string.
|