ArticleslgStudy

mathematics

Jenkins hash function

Jenkins hash function is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Jenkins hash function rather than just read about it. In short: The Jenkins hash functions are a family of non-cryptographic hash functions for multi-byte keys designed by Bob Jenkins. The first one was formally published in 1997.

Jenkins hash function — main illustration
Jenkins hash function — illustration

Key takeaways

  • Jenkins hash function belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Jenkins hash function to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Jenkins hash function from memory before moving on to harder problems.

Reference excerpt

The Jenkins hash functions are a family of non-cryptographic 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 (joaat) 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. Rockstar Games' RAGE engine makes extensive use of this hashing function.

Sample hash values for one_at_a_time hash function.

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 SPIN model checker, for probabilistic error detection. In a paper about this program, researchers Dillinger and Manolios note that lookup2 is "a popular choice among implementers of hash tables and Bloom filters". They study lookup2 and a simple extension of it that produces 96-bit rather than 32-bit hash values. The Netfilter firewall component of Linux, where it replaced an earlier hash function that was too sensitive to collisions. The resulting system, however, was shown to still be sensitive to hash flooding attacks, even when the Jenkins hash is randomized using a secret key. The program that solved the game of kalah used the Jenkins hash function, instead of the Zobrist hashing technique more commonly used for this type of problem; the reasons for this choice were the speed of Jenkins' function on the small representations of kalah boards, as well as the fact that the basic rule of kalah can radically alter the board, negating the benefit of Zobrist's incremental computation of hash functions.

lookup3 The lookup3 function consumes input in 12 byte (96 bit) 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. The lookup3 function was incorporated into Hierarchical Data Format 5 as a checksum for internal data structures based on its relative strength and speed in comparison to CRC-32 and Fletcher-32.

SpookyHash In 2011 Jenkins released a new 128-bit hash function called SpookyHash. SpookyHash is significantly faster than lookup3. Example for V2 (little-endian x64): The short method for less than 192 bytes (43 bytes):

Hash128("The quick brown fox jumps over the lazy dog") 2b12e846aa0693c71d367e742407341b

The standard method for more than 191 bytes (219 bytes):

Hash128("The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog") f1b71c6ac5af39e7b69363a60dd29c49

See also Non-cryptographic hash functions

References

Worked examples

Example 1 — a first encounter with Jenkins hash function

Start with the simplest possible case. Write down what Jenkins hash function claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Jenkins hash function before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Jenkins hash function ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Jenkins hash function

In research
Jenkins hash function appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Jenkins hash function in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Jenkins hash function is common in secondary-school and first-year university syllabi. It links to neighbouring topics Hash function (non-cryptographic), so understanding it makes those chapters shorter.
In everyday life
Look for Jenkins hash function outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Jenkins hash function” →

How to study Jenkins hash function in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Jenkins hash function means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Jenkins hash function out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Jenkins hash function in simple terms?

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

Why does Jenkins hash function matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Jenkins hash function?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Jenkins hash function.

Tags

  • Hash function (non-cryptographic)

Keep exploring