Skip to content

Instantly share code, notes, and snippets.

@sampaiodiego
Created June 24, 2016 01:47
Show Gist options
  • Save sampaiodiego/6ef92f46896fb5167bd074da8683b9db to your computer and use it in GitHub Desktop.
Save sampaiodiego/6ef92f46896fb5167bd074da8683b9db to your computer and use it in GitHub Desktop.
function v1(str) {
var hash = 5381;
for (i = 0; i <str.length; i++) {
char = str.charCodeAt(i);
hash = ((hash <<5) + hash) + char; /* hash * 33 + c */
// hash = hash & hash; // Convert to 32bit integer
}
return hash;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment