Sdk hash api documentation

Hash functions.

Include: #include <dmsdk/dlib/hash.h>
STRUCTS
struct HashState32 Hash state used for 32-bit incremental hashing
struct HashState64 Hash state used for 64-bit incremental hashing
FUNCTIONS
uint32_t dmHashBuffer32(const void* buffer, uint32_t buffer_len) Calculate 32-bit hash value from buffer
uint64_t dmHashBuffer64(const void* buffer, uint32_t buffer_len) calculate 64-bit hash value from buffer
uint32_t dmHashString32(const char* string) Calculate 32-bit hash value from string
uint64_t dmHashString64(const char* string) calculate 64-bit hash value from string
const char* dmHashReverseSafe64(uint64_t hash) get string value from hash
const char* dmHashReverseSafe64(uint64_t hash, uint32_t* length) get string value from hash
void dmHashInit32(HashState32* hash_state, bool reverse_hash) Initialize hash-state for 32-bit incremental hashi...
void dmHashClone32(HashState32* hash_state, HashState32* source_hash_state, bool reverse_hash) Clone 32-bit incremental hash state
void dmHashUpdateBuffer32(HashState32* hash_state, const void* buffer, uint32_t buffer_len) Incremental hashing
uint32_t dmHashFinal32(HashState32* hash_state) Finalize incremental hashing and release associate...
void dmHashRelease32(HashState32* hash_state) Release incremental hashing resources Used to rele...
void dmHashInit64(HashState64* hash_state,  reverse_hash) Initialize hash-state for 64-bit incremental hashi...
void dmHashClone64(HashState64* hash_state, HashState64* source_hash_state,  reverse_hash) Clone 64-bit incremental hash state
void dmHashUpdateBuffer64(HashState64* hash_state, const void* buffer, uint32_t buffer_len) Incremental hashing
uint64_t dmHashFinal64(HashState64* hash_state) Finalize incremental hashing and release associate...
void dmHashRelease64(HashState64* hash_state) Release incremental hashing resources Used to rele...

Functions

dmHashBuffer32

uint32_t dmHashBuffer32(const void* buffer, uint32_t buffer_len)

Calculate 32-bit hash value from buffer

PARAMETERS

const void* buffer Buffer
uint32_t buffer_len Length of buffer

RETURNS

uint32_t hash value

dmHashBuffer64

uint64_t dmHashBuffer64(const void* buffer, uint32_t buffer_len)

calculate 64-bit hash value from buffer

PARAMETERS

const void* buffer Buffer
uint32_t buffer_len Length of buffer

RETURNS

uint64_t hash value

dmHashString32

uint32_t dmHashString32(const char* string)

Calculate 32-bit hash value from string

PARAMETERS

const char* string Null terminated string

RETURNS

uint32_t hash value

dmHashString64

uint64_t dmHashString64(const char* string)

calculate 64-bit hash value from string

PARAMETERS

const char* string Null terminated string

RETURNS

uint64_t hash value

dmHashReverseSafe64

const char* dmHashReverseSafe64(uint64_t hash)

Returns the original string used to produce a hash. Always returns a null terminated string. Returns "" if the original string wasn't found.

PARAMETERS

uint64_t hash hash value

RETURNS

const char* Original string value

dmHashReverseSafe64

const char* dmHashReverseSafe64(uint64_t hash, uint32_t* length)

Reverse hash lookup. Maps hash to original data. It is guaranteed that the returned buffer is null-terminated. If the buffer contains a valid c-string it can safely be used in printf and friends.

PARAMETERS

uint64_t hash hash to lookup
uint32_t* length original data length. Optional argument and NULL-pointer is accepted.

RETURNS

const char* pointer to buffer. 0 if no reverse exists or if reverse lookup is disabled

dmHashInit32

void dmHashInit32(HashState32* hash_state, bool reverse_hash)

Initialize hash-state for 32-bit incremental hashing

PARAMETERS

HashState32* hash_state Hash state
bool reverse_hash true to enable reverse hashing of buffers up to ::DMHASH_MAX_REVERSE_LENGTH

dmHashClone32

void dmHashClone32(HashState32* hash_state, HashState32* source_hash_state, bool reverse_hash)

Clone 32-bit incremental hash state

PARAMETERS

HashState32* hash_state Hash state
HashState32* source_hash_state Source hash state
bool reverse_hash true to enable reverse hashing of buffers up to ::DMHASH_MAX_REVERSE_LENGTH. Ignored if source state reverse hashing is disabled.

dmHashUpdateBuffer32

void dmHashUpdateBuffer32(HashState32* hash_state, const void* buffer, uint32_t buffer_len)

Incremental hashing

PARAMETERS

HashState32* hash_state Hash state
const void* buffer Buffer
uint32_t buffer_len Length of buffer

dmHashFinal32

uint32_t dmHashFinal32(HashState32* hash_state)

Finalize incremental hashing and release associated resources

PARAMETERS

HashState32* hash_state Hash state

RETURNS

uint32_t the hash value

dmHashRelease32

void dmHashRelease32(HashState32* hash_state)

Release incremental hashing resources Used to release assocciated resources for intermediate incremental hash states.

PARAMETERS

HashState32* hash_state Hash state

dmHashInit64

void dmHashInit64(HashState64* hash_state,  reverse_hash)

Initialize hash-state for 64-bit incremental hashing

PARAMETERS

HashState64* hash_state Hash state
reverse_hash true to enable reverse hashing of buffers up to ::DMHASH_MAX_REVERSE_LENGTH

dmHashClone64

void dmHashClone64(HashState64* hash_state, HashState64* source_hash_state,  reverse_hash)

Clone 64-bit incremental hash state

PARAMETERS

HashState64* hash_state Hash state
HashState64* source_hash_state Source hash state
reverse_hash true bool to enable reverse hashing of buffers up to ::DMHASH_MAX_REVERSE_LENGTH. Ignored if source state reverse hashing is disabled.

dmHashUpdateBuffer64

void dmHashUpdateBuffer64(HashState64* hash_state, const void* buffer, uint32_t buffer_len)

Incremental hashing

PARAMETERS

HashState64* hash_state Hash state
const void* buffer Buffer
uint32_t buffer_len Length of buffer

dmHashFinal64

uint64_t dmHashFinal64(HashState64* hash_state)

Finalize incremental hashing and release associated resources

PARAMETERS

HashState64* hash_state Hash state

RETURNS

uint64_t The hash value

dmHashRelease64

void dmHashRelease64(HashState64* hash_state)

Release incremental hashing resources Used to release assocciated resources for intermediate incremental hash states.

PARAMETERS

HashState64* hash_state Hash state

Structs

HashState32

TYPE

struct HashState32

Hash state used for 32-bit incremental hashing


HashState64

TYPE

struct HashState64

Hash state used for 64-bit incremental hashing