diff options
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; +} |
