MetroHash Explained: The Fast Hash for Tables and Caches

MetroHash explained in plain terms means understanding the fast hash that was built to be simple, quick and well mixed, a design from 2014 that turns any input into a 64 or 128-bit fingerprint with a handful of multiply and rotate steps. The central question is why yet another fast hash was needed when MurmurHash already existed, and the answer is that MetroHash is simpler to implement and just as fast, so it gives programmers a hash they can read, trust and drop into any table, and that simplicity is the whole point of the design.

MetroHash is a non-cryptographic hash function designed by J. Andrew Rogers and first published in 2014, producing 64-bit and 128-bit digests. It turns a message of any length into a fixed fingerprint using 64-bit multiplications and rotations, and it is built on the idea that a hash should be easy to audit, which means the design has few moving parts, and that clarity is what makes it unlike the more tangled hashes of its era.

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

Key takeaways

  • MetroHash is a fast hash from 2014, in 64 and 128-bit forms.
  • It was designed by J. Andrew Rogers.
  • It uses multiply and rotate steps for mixing.
  • It is simple to implement and easy to audit.
  • It is used in hash tables, caches and data tools today.

What MetroHash is

MetroHash is a hash that turns data into fingerprints with a small, clean recipe, and that clarity is what makes it unusual among fast hashes. A programmer can read the whole algorithm in an afternoon, which means the design hides no surprises, and because it is easy to audit, teams trust it in code they must maintain for years.

Its signature feature is the multiply and rotate core. Most fast hashes mix with a blend of shifts, xors and adds, but MetroHash leans on 64-bit multiplication, which means each step spreads bits from the low end to the high end in one operation, and because multiplication is fast on modern processors, the hash is quick without being complicated.

The design was a reaction to hashes that were fast but hard to read. MurmurHash worked well yet its internals were fiddly, so Rogers built a hash with the same speed and a simpler shape, because a hash that is easy to understand is a hash that is easy to trust, and that practicality is what made MetroHash worth writing.

It became one of the best-known simple hashes in the world, and it is named in every discussion of hashing for tables. MetroHash fingerprints keys in hash tables and caches, it is copied into data libraries everywhere, and it is still the first example engineers meet when they learn that simplicity can match cleverness, which means the design survives as a quiet workhorse even though it never became a standard.

Its most famous property is its avalanche. A one-bit change in the input flips about half the bits of the output, which means similar keys scatter evenly across a table, and because that spreading is what a hash table needs most, the avalanche is the reason MetroHash performs so well in practice.

Our guide to FNV explains the simplest hash of all, and our guide to MurmurHash explains the fast hash MetroHash set out to simplify.

How MetroHash works

Everything starts with the seed, a starting value that lets the same input hash differently. MetroHash takes a 64-bit seed and mixes it into the state before reading any input, which means the empty message still has a well-defined digest, and because the seed is part of the design, different tables can use different seeds.

Each word begins with a multiplication, which is the heart of the mixing. MetroHash takes a 64-bit word from the message, multiplies it by a large odd constant, and rotates the result, which means every word is scrambled thoroughly, and because the rotation moves high bits back to the low end, the mixing reaches every bit position.

The rounds are what make the design work as a whole. MetroHash repeats its multiply and rotate step several times per word, which means every new word spreads its influence across the whole state, and because the rounds repeat as data flows in, the fingerprint depends on every byte of the message.

The tail spreads the effect further. A message rarely ends on a word boundary, so MetroHash reads the leftover bytes and mixes them in with the same care, which means a short message is hashed as thoroughly as a long one, and because the tail handling is simple, the design stays fast at every size.

The finalisation is what turns the state into a digest. After the last byte, MetroHash runs the state through extra mixing rounds with no new input, which means the digest depends on the whole message and nothing else, and because the final rounds are the same as the mixing rounds, the design needs no special finishing step.

The digest comes from the final state, read out as 64 or 128 bits. MetroHash outputs its wide state directly as the fingerprint, which means the result fits whatever field needs it, and that size is exactly what a hash table bucket or a cache key needs for its lookup.

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 MetroHash works: input words take turns through multiply and rotate rounds, word after word, until a fingerprint emerges.

Comparing MetroHash with other fast hashes

MetroHash is one of several fast hashes built for real programs, and each was built with a different emphasis. MurmurHash is the older general-purpose fast hash, FNV is the simplest hash of all, and MetroHash is the one that pairs simplicity with strong mixing, while each approach trades something for something else.

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

Aspect MetroHash MurmurHash FNV
Core step Multiply and rotate Multiply and xor shift Multiply and xor
Digest size 64 or 128 bits 32 or 128 bits 32, 64 or 128 bits
Seeded Yes Yes Offset basis
Year 2014 2008 1991
Best for Tables and caches General hashing Tiny code

The practical result is that MetroHash is the right choice for tables and caches, MurmurHash suits general hashing, and FNV fits tiny code instead.

Where MetroHash is used

Hash tables use it to spread keys evenly. A table that stores millions of keys needs a hash with a strong avalanche, because clustered keys mean slow lookups, and that spreading is the reason MetroHash earns its keep in everyday programs.

Caches use it to name stored items quickly. A cache that fingerprints content needs a hash that is fast on both long files and short keys, because every request pays the hashing cost, and that speed is the reason MetroHash appears in caching code.

Data tools use it to fingerprint rows and records. A pipeline that hashes data for deduplication needs a hash that never becomes the bottleneck, because a slow hash slows every record, and that pressure is the reason MetroHash is chosen in data processing.

Research uses it as a case study in clean design. Engineers still cite MetroHash when they discuss how a simple recipe can match a complex one, because it is the clearest example of the idea in a real design, and that lesson shapes how new hashes are judged today.

Teaching uses it as the readable example. Courses introduce MetroHash when they explain that a hash can be both fast and understandable, because it is the clearest case of simplicity done well, and a student who understands MetroHash understands why readability matters in security code.

Strengths and limits

The greatest strength of MetroHash is its simplicity. A short, readable algorithm is easy to audit, easy to port and easy to trust, and that strength is real, measured in the libraries that adopted it and confirmed by the engineers who maintain it.

It is also a strength that the design is fast at every size. Short keys and long files both hash quickly, and that evenness is worth more than cleverness in a field where a hash that is only fast on long inputs is a hash that disappoints in practice.

The limits are real, though, and the biggest is that it is not cryptographic. MetroHash is built for speed, not for resisting a determined attacker, which means it must never guard secrets or signatures, and a system that needs real security must use a cryptographic hash instead.

MetroHash checklist

  • Use MetroHash for tables and caches, never for security or passwords.
  • Remember it comes in 64-bit and 128-bit forms.
  • Note the seed lets different tables hash the same key differently.
  • Compare it with MurmurHash to see the simplicity trade-off.
  • Study the avalanche, which is what makes tables fast.
  • Check the tail handling, which keeps short inputs thorough.
  • Keep real digests behind standard hashes for signatures.
  • Read the 2014 design notes to see why it was built.
  • Choose FNV when the code must be as tiny as possible.

Frequently asked questions

What is MetroHash in simple terms?

It is a 2014 fast hash that turns any input into a 64 or 128-bit fingerprint using simple multiply and rotate steps.

Who designed MetroHash?

J. Andrew Rogers, who first published it in 2014 as a simpler, well-mixed answer to MurmurHash.

How is MetroHash different from MurmurHash?

Both are fast non-cryptographic hashes, but MetroHash uses a simpler multiply and rotate core while MurmurHash mixes with more varied steps.

Is MetroHash still secure?

It is fast and well distributed, but it is not a cryptographic hash, so it must never guard secrets, signatures or passwords.

Where is MetroHash used?

In hash tables, in caches, in data tools, and in teaching about clean hash design.

When should I use MetroHash?

When you need a fast, readable hash for tables or caches, when your keys vary in size, or when auditability matters.

The bottom line

MetroHash explained in one line is this: the simple fast hash, a 2014 design that paired multiply and rotate steps with a strong avalanche and showed clarity can match cleverness.

It is proof that readable code can be fast code, and the reason it still matters is that every simple hash designed since has been judged partly by the lesson MetroHash taught.

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

Latest articles

Scroll to Top