retdec
|
compute CRC32 hash, based on Intel's Slicing-by-8 algorithm More...
#include <crc32.h>
Public Types | |
enum | { HashBytes = 4 } |
hash is 4 bytes long More... | |
Public Member Functions | |
CRC32 () | |
same as reset() More... | |
std::string | operator() (const void *data, size_t numBytes) |
compute CRC32 of a memory block More... | |
std::string | operator() (const std::string &text) |
compute CRC32 of a string, excluding final zero More... | |
void | add (const void *data, size_t numBytes) |
add arbitrary number of bytes More... | |
std::string | getHash () |
return latest hash as 8 hex characters More... | |
void | getHash (unsigned char buffer[CRC32::HashBytes]) |
return latest hash as bytes More... | |
void | reset () |
restart More... | |
Private Attributes | |
uint32_t | m_hash |
hash More... | |
compute CRC32 hash, based on Intel's Slicing-by-8 algorithm
Usage: CRC32 crc32; std::string myHash = crc32("Hello World"); // std::string std::string myHash2 = crc32("How are you", 11); // arbitrary data, 11 bytes
or in a streaming fashion:
CRC32 crc32; while (more data available) crc32.add(pointer to fresh data, number of new bytes); std::string myHash3 = crc32.getHash(); Note: You can find code for the faster Slicing-by-16 algorithm on my website, too: http://create.stephan-brumme.com/crc32/ Its unrolled version is about twice as fast but its look-up table doubled in size as well.
retdec::utils::CRC32::CRC32 | ( | ) |
same as reset()
void retdec::utils::CRC32::add | ( | const void * | data, |
size_t | numBytes | ||
) |
add arbitrary number of bytes
std::string retdec::utils::CRC32::getHash | ( | ) |
return latest hash as 8 hex characters
void retdec::utils::CRC32::getHash | ( | unsigned char | buffer[CRC32::HashBytes] | ) |
return latest hash as bytes
std::string retdec::utils::CRC32::operator() | ( | const std::string & | text | ) |
compute CRC32 of a string, excluding final zero
std::string retdec::utils::CRC32::operator() | ( | const void * | data, |
size_t | numBytes | ||
) |
compute CRC32 of a memory block
void retdec::utils::CRC32::reset | ( | ) |
restart
|
private |
hash