diff options
author | quou <quou@disroot.org> | 2024-12-19 19:10:19 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-12-19 19:10:19 +1100 |
commit | 8199bfa31fa59fb060d2939f8612dea575b249d3 (patch) | |
tree | a7df820470c4116c290199e4351a73c39f02036a /qstd/str.c | |
parent | d75880e8a6d4af817c464118ce9a43abca8cf3be (diff) |
hash function
Diffstat (limited to 'qstd/str.c')
-rw-r--r-- | qstd/str.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/qstd/str.c b/qstd/str.c new file mode 100644 index 0000000..a1c1aa1 --- /dev/null +++ b/qstd/str.c @@ -0,0 +1,11 @@ +#include "str.h" + +uint64_t fnv1a64(uint8_t* buf, size_t size) { + size_t i; + uint64_t hash = 0xcbf29ce484222325; + for (i = 0; i < size; i++, buf++) { + hash ^= *buf; + hash *= 0x100000001b3; + } + return hash; +} |