Real World Maths Busters

The Maths Behind Everyday Life

The story, the formula and a worked example — see exactly where this maths shows up in the world around you.

Back to all stories
Technology 3 min read

Digital Fingerprints for Files

A hash function condenses any file into a fixed-length code.

A hash function takes input of any size and produces a fixed-size output — like a 64-character fingerprint. Change one bit of the input and the hash changes completely.

Collision Resistance

SHA-256 produces a 256-bit hash. The chance of two random files having the same hash is 1 in 2²⁵⁶ ≈ 10⁷⁷. You’d need to hash about 2¹²⁸ ≈ 3.4 × 10³⁸ files before a 50% chance of collision (birthday problem).

P(collision)≈n22×2256P(\text{collision}) \approx \frac{n^2}{2 \times 2^{256}}

n = number of hashes computed

How many files for a 50% collision chance?

  1. 1

    Birthday bound

    n≈2×2256=2128.5≈5×1038n \approx \sqrt{2 \times 2^{256}} = 2^{128.5} \approx 5 \times 10^{38}
Answer

About 5 × 10³⁸ files — far more than all files ever created

The takeaway

Hash functions create unique-enough fingerprints that finding two matching ones is practically impossible.

Back to all stories