Hash generator · Guide

SHA256 Hash Collision: How Likely Is It Really?

Collisions must exist in SHA-256 — there are infinitely many inputs and only 2^256 digests. The useful question is whether anyone can find one, and the answer, unlike for MD5 and SHA-1, is no.

The numbers

By the birthday bound, a 50% chance of any random collision arrives after roughly 2^128 hashed items — about 340 undecillion. Hashing a billion items a second since the Big Bang would not come close.

For intuition: you are vastly more likely to see a specific person win a national lottery several times in a row than to encounter an accidental SHA-256 collision in any real system.

Deliberate collisions

This is where MD5 and SHA-1 died. MD5 collisions take seconds on a laptop; SHA-1 fell to a chosen-prefix attack in 2020 at a cost of tens of thousands of dollars. Both are now unusable for anything an attacker benefits from forging.

For SHA-256, no attack better than brute force is known after two decades of public cryptanalysis. The best published results attack reduced-round variants — academically interesting, practically irrelevant.

What to worry about instead

Truncation. A 256-bit digest is collision-resistant; the first 8 characters of it are not. Short prefixes are fine for display and dangerous for verification.

Length extension. Given sha256(secret + message) and the message length, an attacker can compute a valid digest for an extended message without knowing the secret. Use HMAC-SHA256 for authentication and this disappears.

Password speed. SHA-256 is collision-resistant and far too fast for password storage. Different property, different tool.

Frequently asked questions

Has a SHA-256 collision ever been found?

No. None has ever been produced for the full algorithm.

Should I worry about collisions in my database?

No. Accidental collisions are not a practical concern at any realistic scale.

Is SHA-512 safer than SHA-256?

It has a larger digest, but SHA-256 is already beyond brute force. SHA-512 is often faster on 64-bit CPUs, which is a better reason to pick it.

Ready to try it?

Open the free browser-based Hash generator and apply what you just read — no sign-up, runs locally.

Open the Hash generator tool