xxHash Explained: 5 Facts About the Fastest Hash Around

xxHash explained in plain terms means understanding the hash built for pure speed, a design from 2012 that turns data into fingerprints faster than almost anything else in software. The central question is why anyone would choose a hash that offers no security at all, and the answer is that most hashing is not about security, it is about finding things quickly, checking that data arrived intact, and spreading keys evenly across a table, and for those jobs speed is everything, which is the whole point of the design.

xxHash is a non-cryptographic hash function created by Yann Collet and first released in 2012. It turns a message of any length into a short 32-bit or 64-bit fingerprint, and it is built from a handful of multiplications, rotations and exclusive-ors, which means the design does almost nothing per byte, and that leanness is what makes it one of the fastest hashes ever written.

This article gives you five facts about xxHash, explains what it is, how it works, and why it still matters.

Key takeaways

  • xxHash is a non-cryptographic hash from 2012.
  • It was created by Yann Collet for extreme speed.
  • It produces 32-bit and 64-bit fingerprints.
  • It checks data in compression tools and databases.
  • It must never be used where security matters.

What xxHash is

The first fact is that xxHash is a checksum hash, not a security hash. It is built to detect accidental changes and to spread data evenly, not to resist an attacker, which means it is honest about its job, and because it never pretends to be cryptographic, it can spend all of its budget on speed.

The second fact is that it comes in two classic sizes. XXH32 produces a 32-bit fingerprint and XXH64 produces a 64-bit fingerprint, which means the same design serves both small and large jobs, and because the two share one structure, a developer can switch between them without learning a new algorithm.

The third fact is that a newer version arrived in 2019. XXH3 rebuilt the design around modern processors, using wider operations and a secret seed, which means the latest xxHash is faster still on new hardware, and because it keeps the same name, the whole family is easy to follow.

The fourth fact is that it is everywhere in data software. Compression tools use xxHash to check that files survived intact, databases use it to spread keys across shards, and file systems use it to find blocks quickly, which means the design quietly does its job in millions of programs, and that reach is the reason it is so widely known.

The fifth fact is that it survived as a standard, not a curiosity. xxHash showed that a hash could be both simple and blisteringly fast, which means it is still the first choice whenever a program needs a fingerprint in a hurry, and that reputation is the reason it is taught alongside the cryptographic hashes it deliberately is not.

Our guide to hashing explains the fingerprint idea that xxHash is built on, and our guide to SipHash explains the keyed hash that protects hash tables from attackers.

How xxHash works

Everything starts with the seed, a number the caller supplies to vary the output. xxHash mixes the seed into its initial state, which means the same input can produce different fingerprints under different seeds, and because the seed is just a starting value, the design needs no secret key at all.

Each block begins with the input, which is read in chunks of four or eight bytes. The chunk is multiplied by a large prime number and rotated, which means every byte is stirred into the state quickly, and because the operations are so cheap, the design processes data at a pace close to memory speed.

The avalanche is what makes the design work as a whole. After the last chunk, xxHash runs the state through a final mixing step that spreads every bit across the whole fingerprint, which means a single changed byte produces a completely different output, and because the avalanche is thorough, similar inputs never produce similar fingerprints.

The primes spread the effect further. xxHash uses a handful of large prime constants in its multiplications, which means the mixing has no obvious pattern, and because the primes are fixed and public, anyone can study exactly what the hash does.

The tail handling is what keeps the design fast on short inputs. Messages that do not fill a whole chunk are processed byte by byte with the same multiply-and-rotate steps, which means even a tiny string gets the full treatment, and because the tail code is short, the design stays fast on the small keys that hash tables see most.

The fingerprint comes from the final state, read out as a 32-bit or 64-bit number. xxHash outputs the mixed state directly, which means the result fits in a single machine word, and that size is exactly what a hash table or a checksum field needs.

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 xxHash works: data chunks take turns through multiplication and rotation, block after block, until a fingerprint emerges.

Comparing xxHash with other fast hashes

xxHash is one of several fast hashes used in software, and each was built with a different emphasis. MurmurHash is the older non-cryptographic hash with 32-bit and 128-bit outputs, CityHash is the Google hash built for short strings, and xxHash is the one built to be the fastest of all on modern hardware, while each approach trades something for something else.

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

Aspect xxHash MurmurHash CityHash
Output sizes 32 or 64 bits 32, 64 or 128 bits 64 or 128 bits
Security None None None
Year 2012 2008 2011
Designed for Maximum speed General hashing Short strings
Best for Checksums Hash tables String hashing

The practical result is that xxHash is the right choice for checksums, MurmurHash suits hash tables, and CityHash fits string hashing instead.

Where xxHash is used

Compression uses it to check files. Tools built on the LZ4 and zstd formats use xxHash to verify that compressed data survived intact, because a checksum that is slower than the compression would defeat the purpose, which means the hash protects every file without ever becoming the bottleneck.

Databases use it to spread keys. Storage engines hash keys with xxHash to decide which shard or partition holds a record, because a fast hash keeps lookups quick, and that speed is the reason so many databases reach for it first.

File systems use it to find blocks. A file system that must locate data by content needs a fingerprint it can compute in a hurry, and xxHash is fast enough to run on every read, which means the design quietly underpins storage software used around the world.

Games use it to hash assets. Game engines fingerprint textures, models and levels with xxHash to detect changes and to cache work, because an asset pipeline that rehashes everything on every build needs the fastest hash it can get, and that demand is the reason the design is popular in gaming.

Teaching uses it as the speed example. Courses introduce xxHash when they explain that not every hash needs to be cryptographic, because it is the clearest case of a hash built for speed alone, and a student who understands xxHash understands why the field has two kinds of hash at all.

Strengths and limits

The greatest strength of xxHash is its speed. A hash that runs at close to memory bandwidth is fast enough for any job, and that speed is real, measured in the benchmarks that put it at the top and confirmed by the tools that depend on it every day.

It is also a strength that the design is tiny. A hash built from a few multiplications and rotations is easy to implement, easy to audit and easy to port, and that simplicity is worth more than cleverness in a field where a hash nobody can implement quickly is a hash nobody adopts.

The limits are real, though, and the biggest is that it offers no security. xxHash is predictable, so an attacker can craft inputs that collide, which means it must never be used for passwords, signatures or anything an adversary can influence, and its value is entirely in speed and checksums.

xxHash checklist

  • Use xxHash for checksums and hash tables, never for security.
  • Remember it was created by Yann Collet in 2012.
  • Pick XXH32 or XXH64 to match your fingerprint size.
  • Compare it with MurmurHash to see the speed trade-off.
  • Note XXH3 is the faster modern version.
  • Seed it when you need different fingerprints per run.
  • Never use it for passwords, tokens or signatures.
  • Check your tools already use it for data integrity.
  • Choose a cryptographic hash for any job an attacker can touch.

Frequently asked questions

What is xxHash in simple terms?

It is a very fast non-cryptographic hash from 2012 that turns any data into a short 32-bit or 64-bit fingerprint, built for checksums and hash tables rather than security.

Who created xxHash?

Yann Collet, who released it in 2012 alongside his LZ4 compression work, and who later rebuilt it as the even faster XXH3 in 2019.

How is xxHash different from SHA-256?

Both produce fingerprints, but xxHash is non-cryptographic, produces only 32 or 64 bits, and runs at close to memory speed, while SHA-256 is cryptographic, produces 256 bits, and runs far more slowly.

Is xxHash still secure?

No, it was never meant to be secure, an attacker can craft colliding inputs easily, so it is only safe for checksums and hash tables where no adversary controls the input.

Where is xxHash used?

In compression tools, databases, file systems and game engines, wherever a program needs a fingerprint in a hurry.

When should I use xxHash?

When you check data integrity, when you spread keys across a hash table, or when you need the fastest fingerprint available.

The bottom line

xxHash explained in one line is this: the speed hash, a 2012 design from Yann Collet that turned fingerprinting into a race and won it, and still sets the pace today.

It is proof that doing one thing brilliantly can be enough, and the reason it still matters is that every fast hash designed since has been judged partly by the lesson xxHash taught.

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

Latest articles

Scroll to Top