Fast, efficient hash
char *str = "Slash";
unsigned long long hash = slash(str);
- The result is initialized at
1
- For each byte (8 bits):
- Set the result to
(result @ prime) ^ (byte)
- Set the result to
- Return 64 bit unsigned result
@
denotes carry-less multiplication^
denotes exclusive OR (XOR)byte
denotes the current byte being operated onprime
is a constant chosen by a simulated annealing algorithm (0xA171020315130201ULL
)
Licensed under the MIT License by Kabir Shah