Non-cryptographic
Jenkins hash
A family of fast non-cryptographic hash functions designed by Bob Jenkins between 1997 and 2011. Predates MurmurHash and CityHash; its descendants are still in Perl, the Linux kernel, and many C libraries. The defining feature is excellent bit distribution from a small, byte-loop construction.
The three generations
- One-at-a-time hash(1997) , the original. Process bytes one at a time; add, shift, XOR. Used in Perl’s hash table for many years.
- lookup2 / lookup3 (2006) , 32-bit-word-at-a-time processing, much faster.
jhashin the Linux kernel is the lookup3-derived variant. - SpookyHash (2011) , 128-bit output, internal 12-word state. Comparable to MurmurHash3 in design philosophy.
At a glance
| Output | 32 bits (one-at-a-time, lookup3-32), 64-bit (lookup3-64), 128 (Spooky) |
|---|---|
| Designer | Bob Jenkins |
| Throughput | 1-3 GiB/s (lookup3), 5-10 GiB/s (Spooky) |
| Status | Non-cryptographic; vulnerable to hash flooding without seed |
Where it shows up
- Linux kernel ,
jhashfor network-stack flow lookups (now often replaced by SipHash). - Perl , one-at-a-time hash for the dictionary type, since switched to a SipHash variant.
- Cassandra (earlier versions), Glib, BSD , various Jenkins variants.
- SpookyHash , Splunk, indexing pipelines, some database engines.
vs MurmurHash3 vs xxHash3
- Jenkins was the first widely-deployed “modern” non-cryptographic hash; both Murmur and CityHash drew from its ideas.
- For raw speed today on modern CPUs, xxHash3 beats Jenkins on every dimension.
- For tiny footprint (the one-at-a-time variant is ~10 lines of code), Jenkins is still hard to beat.
Hash-flooding caveat
Jenkins is not keyed. Hash tables exposed to attacker-chosen keys need to switch to SipHash or use a randomized seed.
References
- Bob Jenkins , A Hash Function for Hash Table Lookup
- SpookyHash project page
- MurmurHash3 · xxHash3 · SipHash
Quick quiz
Test yourself on jenkins
10 multiple-choice questions. Pick an answer for each, then submit to see explanations.
Q1.Who designed the Jenkins hash family?
Q2.Which Jenkins variant is one-byte-at-a-time?
Q3.Which Linux kernel function descends from Jenkins lookup3?
Q4.Output size of SpookyHash?
Q5.Is Jenkins cryptographic?
Q6.Which language historically used a Jenkins hash for its dict?
Q7.lookup3 vs one-at-a-time main improvement:
Q8.Year SpookyHash was released:
Q9.vs xxHash3 on modern CPUs Jenkins lookup3:
Q10.What's the canonical Jenkins documentation page?