Last active
February 17, 2017 18:32
-
-
Save peteb/68a8ba3e57719cdb155be8e24d697db0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int hash(const char *data) { | |
const char *pos = data; | |
int bit_num = 1; | |
int xored = 0; | |
while (*pos) { | |
int value = (int)*pos << bit_num; | |
int msb = value >> 15; | |
value = (value & 0x7FFF) | msb; | |
pos++; | |
bit_num++; | |
xored ^= value; | |
} | |
return xored ^ (bit_num - 1) ^ 0xCE4B; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment