From 2278df1493e064c197913e49b5d1935942d83448 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 6 May 2025 16:57:32 -0700 Subject: initial import --- src/djb2.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/djb2.c (limited to 'src/djb2.c') diff --git a/src/djb2.c b/src/djb2.c new file mode 100644 index 0000000..43c25b6 --- /dev/null +++ b/src/djb2.c @@ -0,0 +1,14 @@ + +#include + +// dbj2 hash +uint32_t djb2(const char *str) { + uint32_t hash = 5381; + int c; + + while ((c = *str++)) { + hash = ((hash << 5) + hash) + c; + } + + return hash; +} -- cgit v1.2.3