FNV Explained: The Simplest Hash in the Book

FNV explained in plain terms means understanding the hash that does almost nothing and still works, a design from 1991 that turns a string into a fingerprint with just a multiplication and an exclusive-or per byte. The central question is how a hash this simple can be trusted at all, and the answer is that FNV was never trying to be clever, it was trying to be small, fast and good enough for the hash tables of its day, and for that job a multiply and an xor turned out to be exactly enough, which is a lesson in restraint.

FNV is a non-cryptographic hash function created by Glenn Fowler, Landon Curt Noll and Phong Vo at Bell Labs in 1991. It turns a message of any length into a short 32-bit or 64-bit fingerprint, and it is built from a single loop that multiplies the running state by a prime and xors in the next byte, which means the whole algorithm fits in a few lines of code, and that smallness is what made it one of the most copied hashes ever written.

This article explains what FNV is, how it works, and where it runs in the real world.

Key takeaways

  • FNV is a non-cryptographic hash from 1991.
  • It was created at Bell Labs by Fowler, Noll and Vo.
  • It produces 32-bit and 64-bit fingerprints.
  • It uses one multiplication and one xor per byte.
  • It is used in hash tables and in DNS software today.

What FNV is

FNV is a hash that turns a string into a short fingerprint, and that fingerprint is what decides where a key lands in a hash table. A program feeds in a name or a word, FNV mixes it byte by byte, and out comes a number, which means two different strings should land in different buckets, and that promise is what keeps a hash table fast.

Its signature feature is the two-step loop. Most hashes need several operations per byte, but FNV needs only a multiplication by a fixed prime and an exclusive-or with the next byte, which means the design is about as simple as a hash can possibly be, and because the loop is so short, it runs quickly even on the weakest hardware.

The design was a reaction to the hashes of its day. In 1991, hash tables needed a function that was fast on short strings and easy to implement in C, so three Bell Labs researchers wrote one that did the minimum, because a hash that fits in a few lines is a hash that can be dropped into any program without a second thought.

It became one of the best-known hashes in the world, and it is named in every history of hash-table engineering. FNV was built into the Go standard library, used in DNS servers, and copied into countless codebases, which means the design went from a Bell Labs memo to infrastructure in a few years, and that adoption is the reason it is now a landmark.

Its most famous property is the pair of variants. FNV-1 multiplies first and then xors, while FNV-1a xors first and then multiplies, which means the two differ by a single swap, and because the swapped order mixes better, FNV-1a is the version everyone recommends today.

Our guide to hashing explains the fingerprint idea that FNV is built on, and our guide to MD4 explains an older hash that FNV’s simplicity was reacting against.

How FNV works

Everything starts with the offset basis, a fixed number the hash begins from. FNV sets its running state to a large prime-like constant before reading any input, which means the empty string still has a well-defined fingerprint, and because the basis is fixed, the same input always produces the same output.

Each byte begins with the xor step, at least in FNV-1a. The next input byte is xored into the low byte of the running state, which means every byte changes the state before anything else happens, and because the xor comes first, the input influences the multiplication that follows.

The multiplication is what makes the design work as a whole. After the xor, FNV multiplies the state by a large prime number, which means the small change from one byte is spread across the whole state, and because the prime is odd and large, the spreading has no obvious pattern.

The prime spreads the effect further. FNV’s prime was chosen so that multiplication mixes the bits thoroughly, which means a single changed byte produces a completely different fingerprint, and because the prime is fixed and public, anyone can study exactly what the hash does.

The loop repeats until the input runs out. FNV processes one byte at a time, xoring and multiplying, which means the whole message is folded into the state in order, and because the loop is so short, the design stays fast even on the shortest keys that hash tables see most.

The fingerprint comes from the final state, read out as a 32-bit or 64-bit number. FNV outputs the running state directly with no final mixing step, which means the result is ready the moment the last byte is processed, and that directness is what makes the hash so easy to implement.

A dark office desk with a laptop showing a glowing green cipher diagram, a brass key and a notebook beside it
A dark office desk with a laptop showing a glowing green cipher diagram, a brass key and a notebook beside it, shows how FNV works: bytes take turns through xor and multiplication, byte after byte, until a fingerprint emerges.

Comparing FNV with other simple hashes

FNV is one of several simple hashes used in software, and each was built with a different emphasis. The djb2 hash is the other classic tiny hash with a multiply-and-add loop, MurmurHash is the faster modern hash with 32-bit and 128-bit outputs, and FNV is the one built on a prime multiplication with an offset basis, while each approach trades something for something else.

The table below sets out the main contrasts between the leading approaches.

Aspect FNV djb2 MurmurHash
Output sizes 32 or 64 bits 32 bits 32, 64 or 128 bits
Operations Multiply and xor Multiply and add Multiply and rotate
Year 1991 1990s 2008
Designed for Simple hash tables String hashing General hashing
Best for Short strings String hashing Database partitions

The practical result is that FNV is the right choice for short strings, djb2 suits string hashing, and MurmurHash fits database partitions instead.

Where FNV is used

DNS software uses it to hash names. Name servers look up domain names millions of times a day, and FNV is fast enough to hash each name without slowing the lookup, because a resolver that spends its time hashing is a resolver that answers late, and that speed is the reason the design is popular in networking.

Programming languages use it as a built-in hash. The Go standard library ships FNV as its simple hash, because a language needs a hash that is easy to explain and easy to trust, and that inclusion is the reason so many Go programs reach for it first.

Hash tables use it for short keys. A table that stores words or identifiers needs a hash that is quick on tiny inputs, and FNV processes short strings with almost no overhead, which means the design quietly underpins software used around the world.

Embedded systems use it where code size matters. A microcontroller with little flash memory cannot afford a large hash implementation, and FNV fits in a few lines, which means the design is still the right choice where every byte of code counts.

Teaching uses it as the simplest example. Courses introduce FNV when they explain what a hash function is, because it is the clearest case of the idea in its barest form, and a student who understands FNV understands why hashing works at all.

Strengths and limits

The greatest strength of FNV is its simplicity. A hash that fits in a few lines of code can be implemented anywhere, and that simplicity is real, measured in the decades of use and confirmed by the codebases that still carry it.

It is also a strength that the design is fast on short strings. A hash that does one multiplication per byte is quick where it matters most, and that speed is worth more than cleverness in a field where a hash that is slow on small keys is a hash that slows everything down.

The limits are real, though, and the biggest is that it offers no security and mediocre distribution. FNV’s avalanche is weaker than modern hashes, and it is predictable, which means it must never be used where an attacker controls the input, and its value is entirely in simplicity and speed on short keys.

FNV checklist

  • Use FNV for short strings and hash tables, never for security.
  • Remember it was created at Bell Labs in 1991.
  • Choose FNV-1a over FNV-1 for better mixing.
  • Compare it with djb2 to see the simplicity trade-off.
  • Note it produces 32-bit or 64-bit fingerprints.
  • Seed it with the offset basis, never with zero.
  • Never use it for passwords, tokens or signatures.
  • Check your language already ships it in the standard library.
  • Choose a modern hash for any job an attacker can touch.

Frequently asked questions

What is FNV in simple terms?

It is a very simple non-cryptographic hash from 1991 that turns a string into a short fingerprint by multiplying by a prime and xoring in one byte at a time.

Who created FNV?

Glenn Fowler, Landon Curt Noll and Phong Vo, who developed it at Bell Labs in 1991 as a small, fast hash for hash tables.

How is FNV different from djb2?

Both are tiny string hashes, but FNV multiplies by a prime and xors each byte, while djb2 multiplies by 33 and adds each byte, and FNV starts from a fixed offset basis.

Is FNV still secure?

No, it was never meant to be secure, its mixing is weak and its output is predictable, so it is only safe for hash tables where no adversary controls the input.

Where is FNV used?

In DNS software, in the Go standard library, in hash tables, and in embedded systems, wherever a tiny, fast hash is needed.

When should I use FNV?

When you hash short strings, when you need the simplest possible hash, or when you want the classic Bell Labs design.

The bottom line

FNV explained in one line is this: the simplest hash, a 1991 design from Bell Labs that did almost nothing per byte and still became one of the most copied hashes ever written.

It is proof that less can be more, and the reason it still matters is that every hash designed since has been judged partly by the lesson FNV taught.

This article is general information about how FNV works, not advice about choosing encryption for a particular device or system.

Latest articles

Scroll to Top