Skip to content
KinPilot™Learn & Explore
Menu

Grades 9–12 · Computing

Why can different inputs produce the same hash digest?

A hash digest is an output computed from an input by a specified function. Determinism means the same input gives the same output every time the rule is used. In this deliberately weak example, inputs are integers zero through fifteen and the rule keeps only the remainder after division by four.

D17 visual explanationThe deliberately weak toy digest is h(x)=x mod 4 for integers 0 through 15. Inputs 2 and 6 give digests 2 and 2. These distinct inputs collide. Sixteen inputs share four outputs, so some collisions are unavoidable. This is not a cryptographic hash.A tiny digest maps many inputs to few outputsToy rule: h(x) = remainder after division by 4Input 2Input 6h=0h=1h=2h=3Different inputs; the same digest: a collision.This easy toy is not a cryptographic hash.

In the diagramA tiny digest maps many inputs to few outputsToy rule: h(x) = remainder after division by 4Input 2Input 6h=0h=1h=2h=3Different inputs; the same digest: a collision.This easy toy is not a cryptographic hash.

Inputs two and six both produce digest two under the weak remainder-modulo-four rule.

There are four possible outputs: zero, one, two and three. Input two has remainder two. Input six also has remainder two, so these distinct inputs collide. A collision means unequal inputs with equal outputs. Repeating input six twice is not a collision between distinct inputs, even though the two digest values match.

Sixteen inputs cannot all receive unique outputs when only four outputs exist. This is the pigeonhole principle: more items than available categories forces some category to contain multiple items. A digest can discard information, so its output alone does not uniquely identify which of the possible inputs produced it.

Cryptographic hashes also face mathematical collisions when their input space exceeds their fixed output space. Their security goal is not that collisions never exist. Appropriate designs aim to make relevant attacks, such as finding a collision or a preimage, computationally difficult under stated assumptions. This tiny remainder function has no such difficulty.

Hashing is also distinct from encryption. Encryption supports recovery using an appropriate key, whereas a digest is not a lossless encoded copy waiting to be decrypted. A matching toy digest supplies neither secrecy nor sender identity, and by itself cannot establish that two inputs are identical.

About this explanation

Starting knowledge: Compute small division remainders and distinguish a function from its inverse.

Sources

  • Cornell University, CS 5430 — Hashes and Message Digests
← Grades 9–12 topics