diff options
| author | daniel <daniel@planethacker.net> | 2025-05-06 16:57:32 -0700 |
|---|---|---|
| committer | daniel <daniel@planethacker.net> | 2025-05-06 16:57:32 -0700 |
| commit | 2278df1493e064c197913e49b5d1935942d83448 (patch) | |
| tree | 42f06ab2f76e2ddf228bafbb03f79621975a4534 /src/djb2.c | |
initial import
Diffstat (limited to 'src/djb2.c')
| -rw-r--r-- | src/djb2.c | 14 |
1 files changed, 14 insertions, 0 deletions
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 <stdint.h> + +// dbj2 hash +uint32_t djb2(const char *str) { + uint32_t hash = 5381; + int c; + + while ((c = *str++)) { + hash = ((hash << 5) + hash) + c; + } + + return hash; +} |
