libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_hash.h
Go to the documentation of this file.
1/*! \file
2 * \brief Collection of hashing algorithms
3 * \ingroup hashing
4 *
5 * This file contains the hashing API, which
6 * is a collection of various hashing algorithms
7 * for calculating the hashes of either arbitrary
8 * buffers of data or primitive types of specific
9 * sizes.
10 *
11 * \author 2023 Falco Girgis
12 * \copyright MIT License
13 */
14#ifndef GIMBAL_HASH_H
15#define GIMBAL_HASH_H
16
17#include "../core/gimbal_decls.h"
18
19
20/*! \defgroup hashing Hashing
21 * \ingroup algorithms
22 * \brief Collection of hash algorithms.
23*/
24
25//! Default hashing algorithm used internally by libGimbal
26#ifndef gblHash
27# define gblHash gblHashFnv1
28#endif
29
31
32/*! \name Fixed data sizes
33 * \brief Methods for calculating the hash of primitive types
34 * @{
35 */
36
37//! Calculate the hash of a given 32-bit value
39//! Retrieve original 32-bit value from its hash
41//! Calculate the hash of the given 16-bit value
43//! @}
44
45//! Calculates the hash of a given buffer continuing the partial hash from a previous iteration (or taking NULL for none)
46GBL_EXPORT uint16_t gblHashCrc16BitPartial (const void* pData,
47 size_t size,
48 uint16_t* pPartial) GBL_NOEXCEPT;
49//! @}
50
51/*! \name Arbitrarily-sized data
52 * \brief Methods for calculating the hash of generic buffers
53 * \ingroup hashing
54 * @{
55 */
56//! Returns the hash of the given data buffer, calculated using the SIP algorithm
57GBL_EXPORT GblHash gblHashSip (const void* pData, size_t size) GBL_NOEXCEPT;
58//! Returns the hash of the given data buffer, calculated using the MurmurHash32 algorithm
59GBL_EXPORT GblHash gblHashMurmur (const void* pData, size_t size) GBL_NOEXCEPT;
60//! Returns the hash of the given data buffer, calculated using the a custom FNV1 algorithm
61GBL_EXPORT GblHash gblHashFnv1 (const void* pData, size_t size) GBL_NOEXCEPT;
62//! Returns the hash of the given data buffer, calculated using the xxHash algorithm
63GBL_EXPORT GblHash gblHashXx (const void* pData, size_t size) GBL_NOEXCEPT;
64//! Returns the hash of the given data buffer, calculated using the SuperFastHash algorithm
65GBL_EXPORT GblHash gblHashSuperFast (const void* pData, size_t size) GBL_NOEXCEPT;
66//! Returns the hash of the given data buffer, calculated using the Pearson hashing algorithm
67GBL_EXPORT GblHash gblHashPearson (const void* pData, size_t size) GBL_NOEXCEPT;
68//! Returns the hash of the given data buffer, calculated using the Jenkins hashing algorithm
69GBL_EXPORT GblHash gblHashJenkins (const void* pData, size_t size) GBL_NOEXCEPT;
70//! Returns the CRC value of the given data buffer
71GBL_EXPORT GblHash gblHashCrc (const void* pData, size_t size) GBL_NOEXCEPT;
72//! Returns the SHA1 hash calculated for the given data buffer
73GBL_EXPORT GblHash gblHashSha1 (const void* pData, size_t size) GBL_NOEXCEPT;
74//! Returns the MD5 hash calculated for the given data buffer
75GBL_EXPORT GblHash gblHashMd5 (const void* pData, size_t size) GBL_NOEXCEPT;
76//! @}
77
79
80#endif // GIMBAL_HASH_H
#define GBL_NOEXCEPT
#define GBL_DECLS_BEGIN
#define GBL_EXPORT
uint32_t gblUnhash32Bit(GblHash hash)
Retrieve original 32-bit value from its hash.
GblHash gblHashSuperFast(const void *pData, size_t size)
Returns the hash of the given data buffer, calculated using the SuperFastHash algorithm.
GblHash gblHash16Bit(uint16_t value)
Calculate the hash of the given 16-bit value.
GblHash gblHashSip(const void *pData, size_t size)
Returns the hash of the given data buffer, calculated using the SIP algorithm.
GblHash gblHashJenkins(const void *pData, size_t size)
Returns the hash of the given data buffer, calculated using the Jenkins hashing algorithm.
GblHash gblHashPearson(const void *pData, size_t size)
Returns the hash of the given data buffer, calculated using the Pearson hashing algorithm.
GblHash gblHashCrc(const void *pData, size_t size)
Returns the CRC value of the given data buffer.
GblHash gblHashMd5(const void *pData, size_t size)
Returns the MD5 hash calculated for the given data buffer.
GblHash gblHashXx(const void *pData, size_t size)
Returns the hash of the given data buffer, calculated using the xxHash algorithm.
GblHash gblHashFnv1(const void *pData, size_t size)
Returns the hash of the given data buffer, calculated using the a custom FNV1 algorithm.
GblHash gblHashMurmur(const void *pData, size_t size)
Returns the hash of the given data buffer, calculated using the MurmurHash32 algorithm.
uint16_t gblHashCrc16BitPartial(const void *pData, size_t size, uint16_t *pPartial)
Calculates the hash of a given buffer continuing the partial hash from a previous iteration (or takin...
GblHash gblHash32Bit(uint32_t value)
Calculate the hash of a given 32-bit value.
GblHash gblHashSha1(const void *pData, size_t size)
Returns the SHA1 hash calculated for the given data buffer.
uint32_t GblHash
Type representing a calculated numeric hash across the codebase.