Skip to content

Instantly share code, notes, and snippets.

@peteb
Last active February 17, 2017 18:32
Show Gist options
  • Save peteb/68a8ba3e57719cdb155be8e24d697db0 to your computer and use it in GitHub Desktop.
Save peteb/68a8ba3e57719cdb155be8e24d697db0 to your computer and use it in GitHub Desktop.
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