Last active
December 15, 2015 21:39
-
-
Save dbrockman/5327463 to your computer and use it in GitHub Desktop.
Jenkins hash function on strings
This file contains hidden or 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
| function jenkins_hash(s) { | |
| var hash = 0, i = 0, l = s.length; | |
| for (; i < l; ++i) { | |
| hash += s.charCodeAt(i); | |
| hash += (hash << 10); | |
| hash ^= (hash >> 6); | |
| } | |
| hash += (hash << 3); | |
| hash ^= (hash >> 11); | |
| hash += (hash << 15); | |
| return hash; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment