Skip to content

Instantly share code, notes, and snippets.

@hgn
Last active February 14, 2017 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hgn/659246b0b5f6e1adf94199c0722484b0 to your computer and use it in GitHub Desktop.
Save hgn/659246b0b5f6e1adf94199c0722484b0 to your computer and use it in GitHub Desktop.
function alex_hash() {
var hash = 0;
if (this.length == 0) return hash;
for (i = 0; i < this.length; i++) {
char = this.charCodeAt(i);
hash1 = ((char)-hash)+char;
hash2 = ((char<<8)-hash)+char;
hash3 = ((char<<16)-hash)+char;
hash4 = ((char<<24)-hash)+char;
hash = (hash1 ^ hash2 ^ hash3 ^ hash4) & 0xFFFFFF;
}
return hash;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment