blob: c8ba66d19b9f81b3fec58befcbe456d2676d1cb0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "hash.h"
#include <stdint.h>
uint64_t xor64_hash(uint64_t const *const bytes, size_t size) {
uint64_t result = 0;
while (size != 0) {
result ^= bytes[size - 1];
size--;
}
return result;
}
uint64_t djb2_hash(char const *const bytes, size_t size) {
uint64_t hash = 5381;
for (size_t i = 0; i < size; i++) {
hash = ((hash << 5) + hash) + bytes[i];
}
return hash;
}
|