This commit is contained in:
Imbus 2025-09-15 15:50:26 +02:00
commit d6d2856c3a
8 changed files with 174 additions and 0 deletions

14
djb2.c Normal file
View file

@ -0,0 +1,14 @@
#include "hash/djb2.h"
/*
* Simple hash function djb2, as in Daniel J. Berenstein.
*/
uint64_t djb2(const char *str) {
uint64_t h = 5381;
int c;
while ((c = *str++)) h = ((h << 5) + h) + c; // h = h * 33 + c;
return h;
}