vkandy / jenkins-hash-js

Jenkins hash in Javascript which yields both 32-bit and 64-bit hash values

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jenkins Hash

A Javascript implementation of Bob Jenkins' hash for non-cryptographic purposes. This implementaion can yield 32-bit and 64-bit hash values and can be used for hashtable lookups.

What is Jenkins hash?

Jenkins hash is a general purpose hash algorithm created by Bob Jenkins. It takes an input of variable length and processes chunks of 12-bytes each and outputs a hash value as 32 bit or 64 bit hexa decimal integer.

Advantages over other hash algorithms:

  1. Uniform distribution of hashes
  2. Very good avalanche effect
  3. Faster than most hash algorithms in terms of number of instructions used in hash calculation.

Usage

var message = "";
var h32 = Jenkins.hash32(message); // 32-bit hash as hexadecimal string
var h64 = Jenkins.hash64(message); // 64-bit hash as hexadecimal string

References

  • Jenkins, Bob (May 2006). The Hash. Retrieved 2011-08-21.

About

Jenkins hash in Javascript which yields both 32-bit and 64-bit hash values


Languages

Language:JavaScript 100.0%