Skip to content

Instantly share code, notes, and snippets.

@mourner
Created November 22, 2013 14:23
Show Gist options
  • Save mourner/7600648 to your computer and use it in GitHub Desktop.
Save mourner/7600648 to your computer and use it in GitHub Desktop.
Adler 32 checksum implementation in JS
function hash(str) {
for (var i = 0, len = str.length, s1 = 1, s2 = 0; i < len; i++) {
s1 = (s1 + str.charCodeAt(i)) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment