summaryrefslogtreecommitdiff
path: root/src/djb2.c
blob: 43c25b64406d43b59a1d221504fcfe066cb2de8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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;
}