Skip to content

Instantly share code, notes, and snippets.

@copy
Last active April 2, 2016 14:11
Show Gist options
  • Select an option

  • Save copy/69e24bc8b9b75943c5f861f00db18507 to your computer and use it in GitHub Desktop.

Select an option

Save copy/69e24bc8b9b75943c5f861f00db18507 to your computer and use it in GitHub Desktop.
var FNV = {};
/** @const */
var FNV_PRIME = 16777619;
/** @const */
var FNV_BASE = 2166136261;
FNV.hashString = function(str)
{
var hash = FNV_BASE;
for(var i = 0; i < str.length; i++)
{
hash ^= str.charCodeAt(i);
hash = Math.imul(hash, FNV_PRIME);
}
return hash >>> 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment