Aria
2.8.0
|
Calculates the MD5 checksum when reading or writing a text file using ArFunctors. More...
#include <ArMD5Calculator.h>
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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.
anonymous enum |
ArMD5Calculator::ArMD5Calculator | ( | ArFunctor1< const char *> * | secondFunctor = NULL | ) |
Creates a new calculator, with an optional functor.
secondFunctor | the optional functor to be invoked on the current text string after its checksum has been calculated |
|
static |
Calculates the checksum for the specified file.
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 |
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.
|
static |
Converts the given checksum buffer to a displayable text string.
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 |