LogCabin
|
Namespaces | |
namespace | anonymous_namespace{Checksum.cc} |
Enumerations | |
enum | { MAX_LENGTH } |
The number of bytes any checksum algorithm name and digest may occupy. More... | |
Functions | |
std::vector< std::string > | listAlgorithms () |
Returns the names of all available hash functions. | |
uint32_t | calculate (const char *algorithm, const void *data, uint64_t dataLength, char output[MAX_LENGTH]) |
Calculate the checksum for a chunk of data. | |
uint32_t | calculate (const char *algorithm, std::initializer_list< std::pair< const void *, uint64_t >> data, char output[MAX_LENGTH]) |
Calculate the checksum for a chunk of data. | |
uint32_t | length (const char *checksum, uint32_t maxChecksumLength) |
Check to see if the checksum format looks plausible. | |
std::string | verify (const char *checksum, const void *data, uint64_t dataLength) |
Verify data against an existing checksum. | |
std::string | verify (const char *checksum, std::initializer_list< std::pair< const void *, uint64_t >> data) |
Verify data against an existing checksum. |
anonymous enum |
The number of bytes any checksum algorithm name and digest may occupy.
Definition at line 35 of file Checksum.h.
std::vector< std::string > LogCabin::Core::Checksum::listAlgorithms | ( | ) |
Returns the names of all available hash functions.
You can use any of these names in the calculate function.
Definition at line 189 of file Checksum.cc.
uint32_t LogCabin::Core::Checksum::calculate | ( | const char * | algorithm, |
const void * | data, | ||
uint64_t | dataLength, | ||
char | output[MAX_LENGTH] | ||
) |
Calculate the checksum for a chunk of data.
algorithm | The checksum algorithm to use. Most crypto++ hash algorithms may be used, for example, "SHA-256". This function will PANIC if the algorithm is not available (see listAlgorithms()). | |
data | The first byte of the data. | |
dataLength | The number of bytes in the data. | |
[out] | output | The result of the hash function will be placed here. This will be a null-terminated, printable C-string. |
Definition at line 195 of file Checksum.cc.
uint32_t LogCabin::Core::Checksum::calculate | ( | const char * | algorithm, |
std::initializer_list< std::pair< const void *, uint64_t >> | data, | ||
char | output[MAX_LENGTH] | ||
) |
Calculate the checksum for a chunk of data.
algorithm | The checksum algorithm to use. Most crypto++ hash algorithms may be used, for example, "SHA-256". This function will PANIC if the algorithm is not available (see listAlgorithms()). | |
data | An list of (pointer, length) pairs describing what to checksum. | |
[out] | output | The result of the hash function will be placed here. This will be a null-terminated, printable C-string. |
Definition at line 203 of file Checksum.cc.
uint32_t LogCabin::Core::Checksum::length | ( | const char * | checksum, |
uint32_t | maxChecksumLength | ||
) |
Check to see if the checksum format looks plausible.
checksum | What might be a checksum as generated by calculate(). |
maxChecksumLength | The total number of bytes in the buffer containing checksum, including the null terminator (if any). |
Definition at line 217 of file Checksum.cc.
std::string LogCabin::Core::Checksum::verify | ( | const char * | checksum, |
const void * | data, | ||
uint64_t | dataLength | ||
) |
Verify data against an existing checksum.
checksum | A null-terminated checksum returned from calculate() or whose format has been verified by length(). The algorithm name in this checksum will determine which checksumming algorithm to use. |
data | The first byte of the data. |
dataLength | The number of bytes in the data. |
Definition at line 232 of file Checksum.cc.
std::string LogCabin::Core::Checksum::verify | ( | const char * | checksum, |
std::initializer_list< std::pair< const void *, uint64_t >> | data | ||
) |
Verify data against an existing checksum.
checksum | A null-terminated checksum returned from calculate() or whose format has been verified by length(). The algorithm name in this checksum will determine which checksumming algorithm to use. |
data | An list of (pointer, length) pairs describing what to checksum. |
Definition at line 239 of file Checksum.cc.