From 9cb655becbdb58c7dfe9f6e72f8915149c1fce61 Mon Sep 17 00:00:00 2001 From: nirav Date: Sun, 29 Nov 2020 13:16:53 +0000 Subject: Initial commit --- fnv.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 fnv.c (limited to 'fnv.c') diff --git a/fnv.c b/fnv.c new file mode 100644 index 0000000..af6532c --- /dev/null +++ b/fnv.c @@ -0,0 +1,26 @@ +#include +#include + +uint64_t fnv1_64(const void *src, size_t len) +{ + const unsigned char *d = (const unsigned char *)src; + uint64_t h = 0xcbf29ce484222325; + size_t i; + for (i = 0; i < len; i++) { + h *= 0x100000001b3; + h ^= d[i]; + } + return h; +} + +uint64_t fnv1a_64(const void *src, size_t len) +{ + const unsigned char *d = (const unsigned char *)src; + uint64_t h = 0xcbf29ce484222325; + size_t i; + for (i = 0; i < len; i++) { + h ^= d[i]; + h *= 0x100000001b3; + } + return h; +} -- cgit v1.2.3