Birthday attack explained in plain terms means understanding the maths trick that finds two inputs with the same hash far sooner than anyone expects, a collision attack built on the famous birthday paradox. The central question is why a hash with billions of possible outputs can be broken with far fewer tries, and the answer is that pairs multiply fast, so 23 people make 253 pairs and a collision becomes likely long before the space runs out.
A birthday attack is a generic collision attack against a hash function, observed independently by Merkle and Yuval in 1979. It needs only about 2 to the power of n over 2 tries to find a collision in an n-bit hash, which means a 128-bit hash falls in about 2 to the power of 64 tries, and because the attack treats the hash as a black box, it works against every hash function ever built.
This article sets out five facts about birthday attacks, what they are, how they work, and where they run in the real world.
Key takeaways
- A birthday attack finds hash collisions with few tries.
- Twenty-three people give a better than even chance of a match.
- An n-bit hash needs only about 2 to the n over 2 tries.
- SHA-256 gives 128 bits of collision security.
- Merkle and Yuval described the attack in 1979.
What a birthday attack is
A birthday attack is a collision attack that turns the birthday paradox into a weapon against hash functions, and that paradox is what makes it unusual among attacks. Each pair of inputs is a fresh chance of a collision, which means the odds grow with the square of the tries, and because pairs multiply so fast, the attack succeeds long before the output space is exhausted.
Its signature feature is the square-root bound. Most brute-force attacks need 2 to the power of n tries against an n-bit hash, but a birthday attack needs only about 2 to the power of n over 2, which means collision security is always half the output length, and because the bound is pure maths, no hash design can escape it.
The attack was a reaction to the belief that a big hash was enough. Designers assumed a 128-bit output meant 128-bit security, so Merkle and Yuval asked whether collisions came cheaper, because a collision needs any two inputs to agree rather than one to match a target, and that practicality is what made the birthday attack worth publishing.
It became one of the best-known attacks in the world, and it is named in every discussion of the field. Yuval showed the attack could forge a signed contract by preparing two batches of variations, one for a 500,000-dollar price and one for 200,000 dollars, NIST states directly that collision resistance strength in bits equals half the output size, hashes under 160 bits are considered inherently insecure, and it is still the first example engineers meet when they learn that a hash must be twice as long as its collision security, which means the attack survives as a lesson even though it is nearly fifty years old.
Our guide to hashing explains the wider family the birthday attack targets, and our guide to SHA-3 explains a modern hash built with the birthday bound in mind.
How a birthday attack works
Everything starts with the paradox, which sets the attacker’s maths. A birthday attack relies on the fact that 23 people give a 50.7 percent chance of a shared birthday, which means the odds turn in the attacker’s favour early, and because the same maths governs hashes, the collision arrives far sooner than intuition suggests.
Each step begins with a random input, which is hashed and stored. A birthday attack picks a message, computes its hash, which means fresh data arrives at every step, and because each new hash is compared against all the stored ones, every try adds many chances at once.
The list lookup is what makes the design work as a whole. After hashing, the attacker checks whether the value is already in the list, which means a match ends the attack, and because the list holds every earlier hash, the number of pairs checked grows quadratically.
The square-root bound spreads the effect further. A birthday attack expects a collision after about 2 to the power of n over 2 evaluations, which means a 256-bit hash like SHA-256 falls in about 2 to the power of 128 tries, and because the bound is exact, the security of every hash can be read off its length.
The chosen-message twist is what turns the trick into a forgery. An attacker with control over the messages can prepare two batches of harmless variations, which means the collision can be steered between two chosen meanings, and because Yuval’s contract example showed the trick in 1979, the attack proved that collisions can carry real fraud.
The result comes from the matching pair, read out as two inputs with one hash. A birthday attack ends with a collision in hand, which means the result is a pair that breaks the hash’s promise whatever the system, and that pair is exactly what an attacker needs to swap one document for another.

Comparing birthday attacks with other hash attacks
A birthday attack is one of several attacks built to break hash functions, and each was built with a different emphasis. A preimage attack is the targeted method built to match one chosen output, a second-preimage attack is the variant built to match one chosen input, and a birthday attack is the one built to find any two inputs that agree, while each approach trades something for something else.
The table below sets out the main contrasts between the leading approaches.
| Aspect | Birthday attack | Preimage attack | Second preimage |
|---|---|---|---|
| Goal | Any two inputs agree | Match one output | Match one input |
| Work for n-bit hash | About 2 to the n over 2 | About 2 to the n | About 2 to the n |
| Attacker control | Full, any messages | None over target | None over target |
| Works on every hash | Yes, generic | Yes, generic | Yes, generic |
| Best for | Collisions and forgery | Reversing a hash | Swapping one file |
The practical result is that a birthday attack is the right choice for collisions and forgery, a preimage attack suits reversing a hash, and a second-preimage attack fits swapping one file instead.
Where birthday attacks are used
Researchers use them to set hash lengths. Cryptographers size new hashes at twice the wanted collision security, because the birthday bound halves the strength, and that rule is the reason the attack earns its keep in standards work.
Attackers use them against short hashes. A 64-bit hash falls in about 2 to the power of 32 tries, because the bound is so small, and that weakness is the reason short hashes are considered inherently insecure.
Auditors use them inside security reviews. A review checks that signatures hash long enough to resist collisions, because a short hash invites Yuval’s contract trick, and that check is the reason the birthday attack appears in audits far beyond its research origins.
Benchmarking uses them as the collision reference. Engineers still quote the birthday bound when they discuss how a hash should behave, because it is the clearest example of maths setting a hard limit, and that number shapes how new hashes are measured.
Teaching uses them as the paradox example. Courses introduce birthday attacks when they explain that pairs multiply faster than intuition, because it is the clearest case of probability beating expectation, and a student who understands birthday attacks understands why hash length is a security decision.
Strengths and limits
The greatest strength of a birthday attack is that it works on every hash. An attack that treats the function as a black box needs no weakness in the design, and that strength is real, measured in the bound itself and confirmed by the hash lengths it forced.
It is also a strength that the attack is simple to run. A list and a hash function are all it takes, and that simplicity is worth more than cleverness in a field where an attack that needs exotic maths is an attack with a small audience.
The limits are real, though, and the biggest is the sheer work at modern lengths. A birthday attack on SHA-256 needs about 2 to the power of 128 tries, which means it is infeasible in practice, and a system that uses a long enough hash is safe from it by design.
Birthday attack checklist
- Use 256-bit hashes for collision security, never short ones.
- Remember 23 people give a better than even chance.
- Note collision security is half the output length.
- Compare it with preimage attacks to see two kinds of work.
- Study the pairs, which is what makes the odds grow.
- Check the hash length, since short hashes fall fast.
- Keep real signatures behind long, modern hashes.
- Read Merkle and Yuval to see how the attack was found.
- Choose SHA-256 or longer when collisions must be infeasible.
Frequently asked questions
What is a birthday attack in simple terms?
It is an attack that finds two different inputs with the same hash, using the birthday paradox to need far fewer tries than expected.
Who described the birthday attack?
Merkle and Yuval, who independently observed in 1979 that collisions need only about 2 to the power of n over 2 tries.
How is a birthday attack different from a preimage attack?
Both break hashes, but a birthday attack finds any two inputs that agree, while a preimage attack must match one chosen output.
Is a birthday attack still a threat?
It is a known and defended threat, but modern 256-bit hashes need about 2 to the power of 128 tries, which is infeasible.
Where are birthday attacks used?
In setting hash lengths, in breaking short hashes, in security audits, and in teaching about collision resistance.
When should I worry about birthday attacks?
When you choose a hash length, when you sign documents, or when you study collision resistance.
The bottom line
Birthday attack explained in one line is this: the paradox that halves hash security, a 1979 observation that 23 people and a square root are all it takes to show that collisions come cheaper than anyone thought.
It is proof that counting pairs beats counting possibilities, and the reason it still matters is that every hash length chosen since has been judged partly by the lesson the birthday attack taught.
This article is general information about how a birthday attack works, not advice about choosing encryption for a particular device or system.







