Course contentsShow
← Computer Science
Lesson 2420 of 2,87254. Cryptography FundamentalsFree lesson

What is a Hash Function?

Understanding hash functions as one-way mathematical functions that map arbitrary data to fixed-size outputs.

What is a Hash Function?

You'll learn: What hash functions are and why they're fundamental to modern cryptography and data integrity.

The Core Concept

A hash function is a mathematical algorithm that takes an input of any size—a single character, a document, or an entire movie file—and transforms it into a fixed-size output called a hash or digest. Think of it like a fingerprint for data: no matter how large the original document, the hash is always the same compact size.

The One-Way Property

The defining characteristic of a cryptographic hash function is that it's a one-way function. You can easily compute the hash from the input data, but you cannot reverse the process to recover the original data from the hash. It's like mixing paint colors—once you've mixed red and blue to get purple, you can't separate them back out.

Key Properties

A good cryptographic hash function must satisfy:

  • Deterministic: The same input always produces the same hash
  • Fast to compute: Generating the hash should be quick
  • Avalanche effect: Changing even one bit in the input completely changes the hash output
  • Collision resistant: It should be extremely difficult to find two different inputs that produce the same hash
  • Pre-image resistant: Given a hash, it should be computationally infeasible to find the original input

Why They Matter

Hash functions verify data integrity (has this file been tampered with?), store passwords securely (without keeping the actual password), and enable digital signatures—all concepts you've encountered in your cryptography journey.

Key Takeaway: Hash functions are one-way mathematical transformations that convert arbitrary data into fixed-size "fingerprints," enabling secure verification without revealing the original information.