Jenkins hash function


The Jenkins hash functions are a collection of hash functions for multi-byte keys designed by Bob Jenkins. The first one was formally published in 1997.

The hash functions

one_at_a_time

Jenkins's one_at_a_time hash is adapted here from a WWW page by Bob Jenkins, which is an expanded version of his Dr. Dobb's article. It was originally created to fulfill certain requirements described by Colin Plumb, a cryptographer, but was ultimately not put to use.

uint32_t jenkins_one_at_a_time_hash

Sample hash values for one_at_a_time hash function.

one_at_a_time
0xca2e9442
one_at_a_time
0x519e91f5

The avalanche behavior of this hash is shown on the right.
Each of the 24 rows corresponds to a single bit in the 3-byte input key, and each of the 32 columns corresponds to a bit in the output hash. Colors are chosen by how well the input key bit affects the given output hash bit: a green square indicates good mixing behavior, a yellow square weak mixing behavior, and red would indicate no mixing. Only a few bits in the last byte of the input key are weakly mixed to a minority of bits in the output hash.
Standard implementations of the Perl programming language prior to version 5.28 included Jenkins's one-at-a-time hash or a hardened variant of it, which was used by default.

lookup2

The lookup2 function was an interim successor to one-at-a-time. It is the function referred to as "My Hash" in the 1997 Dr. Dobbs journal article, though it has been obsoleted by subsequent functions that Jenkins has released. Applications of this hash function are found in:
The lookup3 function consumes input in 12 byte chunks. It may be appropriate when speed is more important than simplicity. Note, though, that any speed improvement from the use of this hash is only likely to be useful for large keys, and that the increased complexity may also have speed consequences such as preventing an optimizing compiler from inlining the hash function.

SpookyHash

In 2011 Jenkins released a new 128-bit hash function called SpookyHash. SpookyHash is significantly faster than lookup3.
Example for V2 :
The short method for less than 192 bytes :
Hash128
2b12e846aa0693c71d367e742407341b
The standard method for more than 191 bytes :
Hash128
f1b71c6ac5af39e7b69363a60dd29c49