Skip to content

Instantly share code, notes, and snippets.

@MattiasFestin
Last active August 29, 2015 14:20
Show Gist options
  • Save MattiasFestin/24f40129d2a7689b6b21 to your computer and use it in GitHub Desktop.
Save MattiasFestin/24f40129d2a7689b6b21 to your computer and use it in GitHub Desktop.
JavaScript ES6 non-secure hash function
let hash = (o) => {
return padLeft(uneval(o)
.split('')
.map((c) => c.charCodeAt(0))
.reduce((x,y) => {
let v = ((y<<5)-y)+x;
return modPow(0xBCD1B799D, v && v, 0x7FFFFFFF);
})
.toString(16)
.toUpperCase(),'0',9);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment