libgslutil
1.2.3
|
Functions | |
uint32_t | gsl_string_hash (const char *data, int len) |
Compute string hash. More... | |
uint32_t | gsl_memory_hash (const struct iovec *datv, int datvcnt) |
Compute memory vector hash. More... | |
uint32_t | gsl_crc32 (uint32_t seed, const char *data, uint32_t len)) |
Compute CRC32 checksum. More... | |
void | gsl_sha256 (const char *data, uint32_t len, char *sha)) |
Compute SHA-256 hash. More... | |
struct gsl_sha256_ctx * | gsl_sha256_alloc (void)) |
Allocate SHA-256 incremental hash object. | |
void | gsl_sha256_incr_hash (struct gsl_sha256_ctx *ctx, const char *data, uint32_t len)) |
Perform incremental hash of data block. More... | |
void | gsl_sha256_finish (struct gsl_sha256_ctx *ctx, char *sha)) |
Finalise incremental hash, free hash object. More... | |
A set of hash functions and CRC computations.
uint32_t gsl_string_hash | ( | const char * | data, |
int | len | ||
) |
Compute string hash.
data | Pointer to data or C string. |
len | Size of data in bytes, or -1 for C strings. |
This function computes a string hash using the LOOKUP3 hash from Bob Jenkins. This hash is intended as a fairly collision-resistant way of hashing ASCII strings. It is also a fast hash for arbitrary binary data. The 32-bit return value may be truncated to a smaller length as necessary.
If data is a C string, pass -1 in len to compute over the length of the string. Otherwise, pass the number of bytes to compute the hash over in len.
uint32_t gsl_memory_hash | ( | const struct iovec * | datv, |
int | datvcnt | ||
) |
Compute memory vector hash.
datv | Pointer to array of memory regions. |
datvcnt | Number of entries in datv. |
This function computes a hash using the LOOKUP3 hash from Bob Jenkins. The 32-bit return value may be truncated to a smaller length as necessary.
uint32_t gsl_crc32 | ( | uint32_t | seed, |
const char * | data, | ||
uint32_t | len | ||
) |
Compute CRC32 checksum.
seed | Initial seed value. |
data | Pointer to data. |
len | Size of data in bytes. |
This function computes the CRC32 of the given data. You can perform incremental CRC by passing the result of one CRC operation as the seed value of the next.
When seed starts at 0xFFFFFFFF and the final result is XORed with 0xFFFFFFFF, this implementation is compatible with CRC-32-IEEE 802.3 (used in Ethernet et al.).
void gsl_sha256 | ( | const char * | data, |
uint32_t | len, | ||
char * | sha | ||
) |
Compute SHA-256 hash.
data | Pointer to data. |
len | Size of data in bytes. |
sha | A 32-byte buffer into which the digest will be written. |
This function computes the SHA-256 hash of the given data.
void gsl_sha256_incr_hash | ( | struct gsl_sha256_ctx * | ctx, |
const char * | data, | ||
uint32_t | len | ||
) |
Perform incremental hash of data block.
ctx | SHA-256 incremental hash object. |
data | Pointer to data. |
len | Size of data in bytes. |
void gsl_sha256_finish | ( | struct gsl_sha256_ctx * | ctx, |
char * | sha | ||
) |
Finalise incremental hash, free hash object.
ctx | SHA-256 incremental hash object. Will be freed. |
sha | A 32-byte buffer into which the digest will be written. |