libhash/djb2.c
2025-09-15 15:50:26 +02:00

14 lines
253 B
C

#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;
}