Course contentsShow
← Security
Lesson 199 of 3,0525. Cryptographic Hashing and MACsFree lesson

Preimage Resistance

Learning why it must be computationally infeasible to find an input that produces a given hash output.

Preimage Resistance

What You'll Learn

You'll understand why a good cryptographic hash function must make it computationally infeasible to reverse-engineer an input from its hash output.


The Core Idea

Preimage resistance is a fundamental security property of cryptographic hash functions. It means that given a hash output h, it should be practically impossible to find any input m such that hash(m) = h.

Think of it like a one-way mirror or a paper shredder analogy: you can easily shred a document (compute the hash), but reconstructing the original document from the shredded pieces (finding the preimage) should be impossible in practice.

Why This Matters

If an attacker could find preimages easily, they could:

  • Forge passwords: Given a password hash from a database, find a password that produces that hash
  • Break digital signatures: Find a message that matches a signature's expected hash
  • Compromise certificate validation: Create fraudulent certificates that hash to expected values

What "Computationally Infeasible" Means

For a hash function producing n-bit outputs, finding a preimage should require approximately 2^n attempts on average through brute force. For SHA-256 (256 bits), that's 2^256 operations — far beyond the capability of any current or foreseeable computer.

Real-World Context

When you store a password hash in a database, preimage resistance ensures that even if attackers steal the hash, they cannot efficiently recover the original password (assuming it's strong). They're forced to try countless possibilities, which takes too much time and resources.


Key Takeaway: Preimage resistance ensures hash functions work as one-way transformations—easy to compute forward, but computationally infeasible to reverse—protecting systems from attackers trying to recover original inputs from their hash values.