FastHash explained in plain terms means understanding the one-mix hash that keeps tables simple, a design from 2012 that turns each 64-bit word through a single xor-shift-multiply step. The central question is why one mixing step can hash well enough when other designs use long chains, and the answer is that a good multiply spreads bits further than a chain of small steps, so FastHash does in one mix what older hashes did in many, and that economy is the whole point of the design.
FastHash is a fast non-cryptographic hash function published in C by Zilong Tan under the MIT licence, producing a 64-bit digest. It turns a message into a fingerprint by feeding its words through a mix function and folding them into one running state, and it is built on the idea that a hash should be small enough to port anywhere, which means the design fits in about thirty lines, and that brevity is what makes it unlike the hashes of its era.
This article explains what FastHash is, how it works, and where it runs in the real world.
Key takeaways
- FastHash is a fast hash from 2012, created by Zilong Tan.
- It produces a 64-bit digest, with a 32-bit folded variant.
- It is built on one mix step: xor-shift, multiply, xor-shift.
- It reads the input eight bytes at a time, little-endian.
- It is seeded, so one key can hash differently per table.
What FastHash is
FastHash is a hash that turns a message into a fingerprint with a single repeated mix, and that simplicity is what makes it unusual among fast hashes. Each step passes a word through the mix and folds it into the state, which means the mixing happens in one place, and because the mix is the same every time, the hash is easy to reason about.
Its signature feature is the mix function. Most hashes mix with rotations, xors and additions in long chains, but FastHash xors a word right by 23, multiplies by a fixed constant and xors right by 47, which means every output bit depends on every input bit at once, and because the multiply is 64 bits wide, the avalanche is stronger than a chain of small steps.
The design was a reaction to the bloat of the standard library. The hash functions shipped with most languages were decades old and hard to port, so Tan published a hash that was both fast and tiny, because a hash table deserves a hash anyone can carry, and that practicality is what made FastHash worth publishing.
It became one of the best-known small hashes in the world, and it is named in every discussion of the field. FastHash is ported to Lua, Go, Python, JavaScript and Groovy, it is packed into countless small projects, and it is still the first example engineers meet when they learn that a hash can be thirty lines long, which means the design survives as a tool even though newer hashes have arrived.
Its most famous property is its portability. The whole algorithm is a seed, a length, a mix and a multiply, which means it runs anywhere 64-bit integers wrap, and because that behaviour is the same on every platform, the hash gives identical results everywhere.
Our guide to xxHash explains the earlier speed champion it was measured against, and our guide to wyhash explains the multiply-and-fold hash that took the same idea further.
How FastHash works
Everything starts with the seed and the length, which initialise the state. FastHash xors the seed with the input length multiplied by a fixed constant, which means the starting state depends on both, and because the length is part of the state, inputs of different lengths start from different places.
Each step begins with the input words, which are read eight bytes at a time. FastHash takes the next little-endian 64-bit word of the message, which means fresh data arrives at every step, and because the words are wide, the hash absorbs data quickly.
The mix is what makes the design work as a whole. Each word passes through the mix step, then is xored into the state, which means the value is scrambled thoroughly, and because the mix runs before the fold, every word is mixed before it meets the state.
The multiply spreads the effect further. After each fold, FastHash multiplies the state by the same fixed constant, which means the state is stirred after every word, and because the multiply is 64 bits wide, the mixing builds up as data flows in.
The tail is what turns the last bytes into a word. For one to seven leftover bytes, FastHash packs them into a single little-endian word and folds it in the same way, which means short inputs are handled rather than ignored, and because the tail uses the same mix, the design needs no separate machinery for the end.
The digest comes from the final state, read out after one last mix. FastHash runs the mix over the state once more and returns the result, which means the digest depends on the whole message and nothing else, and that size is exactly what a hash table or a cache needs for its lookup key.

Comparing FastHash with other fast hashes
FastHash is one of several fast hashes built for hash tables, and each was built with a different emphasis. xxHash is the earlier champion built on prime multiplication and rotation, wyhash is the later hash built on a single wide multiplication, and FastHash is the one built on a single small mix, while each approach trades something for something else.
The table below sets out the main contrasts between the leading approaches.
| Aspect | FastHash | xxHash | wyhash |
|---|---|---|---|
| Core operation | Mix and multiply | Multiply and rotate | Multiply and fold |
| Digest size | 64 or 32 bits | 32, 64 or 128 bits | 64 bits |
| Seeded | Yes | Yes, with a seed | Yes, with a secret |
| Year | 2012 | 2012 | 2019 |
| Best for | Simple fast tables | General hashing | Fastest hash tables |
The practical result is that FastHash is the right choice for simple fast tables, xxHash suits general hashing, and wyhash fits fastest hash tables instead.
Where FastHash is used
Small projects use it as their default hash. A project that needs a hash without a dependency reaches for FastHash, because it is thirty lines that anyone can paste in, and that portability is the reason it runs in real programs rather than only in benchmarks.
Hash tables use it to spread keys with a small fingerprint. A table that stores short keys wants a hash that is both fast and well distributed, because a slow hash becomes the bottleneck, and that speed is the reason FastHash earns its keep in language runtimes.
Scripting languages use it as a teaching port. Lua, Go and Python guides introduce FastHash when they show how a hash is ported, because it is the clearest case of the idea in a real design, and a student who ports FastHash understands how wrapping arithmetic works.
Benchmarking uses it as a simplicity reference. Engineers still quote FastHash when they discuss how small a hash can be, because it is the clearest example of one mix paying off, and that number shapes how new hashes are measured.
Teaching uses it as the mix example. Courses introduce FastHash when they explain that one good multiply can hash, because it is the clearest case of the idea in a real design, and a student who understands FastHash understands why constants matter in hash design.
Strengths and limits
The greatest strength of FastHash is its size. A hash that fits in thirty lines can be audited in an afternoon, and that strength is real, measured in the ports it collected and confirmed by the projects that adopted it.
It is also a strength that the design is seeded. A seed lets one key hash differently in different tables, and that flexibility is worth more than cleverness in a field where a hash that cannot vary is a hash that invites attack.
The limits are real, though, and the biggest is that every step is reversible. An attacker who knows the seed can run the mix backwards and recover short inputs, which means it must never guard a secret, and a system that faces hostile inputs must use a keyed hash with stronger guarantees instead.
FastHash checklist
- Use FastHash for hash tables, never for security or passwords.
- Remember it hashes with one mix step, not a chain.
- Note the digest is 64 bits, with a 32-bit folded variant.
- Compare it with xxHash to see two kinds of fast design.
- Study the mix, which is xor-shift, multiply, xor-shift.
- Check the seed, since the same key hashes differently per seed.
- Keep real digests behind standard hashes for signatures.
- Read Tan’s C reference to see how small it really is.
- Choose a keyed hash when inputs may be hostile.
Frequently asked questions
What is FastHash in simple terms?
It is a 2012 fast hash that turns any input into a 64-bit fingerprint by passing each word through one mix step.
Who created FastHash?
Zilong Tan, who published it in C under the MIT licence as a small, fast, portable hash.
How is FastHash different from xxHash?
Both are fast 64-bit hashes, but FastHash mixes with a single xor-shift-multiply step while xxHash mixes with primes and rotations.
Is FastHash still secure?
It is fast and well tested, but it is not a cryptographic hash, and its steps are reversible, so it must never guard secrets.
Where is FastHash used?
In small projects, in hash tables, in scripting-language ports, in benchmarking, and in teaching about hash design.
When should I use FastHash?
When you need a tiny portable hash, when your inputs are trusted, or when you study single-mix hash design.
The bottom line
FastHash explained in one line is this: the one-mix hash, a 2012 design that turned a single xor-shift-multiply step into a portable hash and taught the field that small can be fast.
It is proof that brevity is a feature, and the reason it still matters is that every small hash designed since has been judged partly by the lesson FastHash taught.
This article is general information about how FastHash works, not advice about choosing encryption for a particular device or system.







