Files
bluelib/core/hash.c

19 lines
323 B
C
Raw Normal View History

#include <blue/core/hash.h>
2024-11-14 23:12:09 +00:00
#include <stddef.h>
#include <stdint.h>
#define FNV1_OFFSET_BASIS 0xcbf29ce484222325
#define FNV1_PRIME 0x100000001b3
uint64_t b_hash_string(const char *s)
{
uint64_t hash = FNV1_OFFSET_BASIS;
for (size_t i = 0; s[i]; i++) {
hash ^= s[i];
hash *= FNV1_PRIME;
}
return hash;
}