Skip to content

Instantly share code, notes, and snippets.

@linuxenko
Created February 16, 2016 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linuxenko/58af8c4606ac4e5cdaae to your computer and use it in GitHub Desktop.
Save linuxenko/58af8c4606ac4e5cdaae to your computer and use it in GitHub Desktop.
function jenkinsHash(str) {
    for (var hash = 0, i = 0, len = str.length; i < len; ++i) {
        hash += (str.charCodeAt(i) >>> 0);
        hash = hash >>> 0
        hash += ((hash << 10) >>> 0);
        hash = hash >>> 0
        hash ^= ((hash >>> 6) >>> 0);
        hash = hash >>> 0
    }
    hash += ((hash << 3) >>> 0);
    hash = hash >>> 0
    hash ^= ((hash >>> 11) >>> 0);
    hash = hash >>> 0
    hash += ((hash << 15) >>> 0);
    hash = hash >>> 0
    return hash >>> 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment