What is a Hash Function?

A simple introduction to digital fingerprints

Think of a hash as a digital fingerprint

Fingerprint icon

Human Fingerprint

Unique to each person

→
biometric-security

Digital Hash

Unique to each piece of data

Simple Definition with Example

A hash function takes any input (text, file, data) and creates a fixed-size fingerprint called a hash.

Basic Example:

Input (text):
"hello"
↓
SHA-256 Algorithm:
processes the input...
↓
Output (hash : always 64 chars):
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

The Avalanche Effect:

See what happens when we change just one character:

Original
"hello"
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
Changed (+ "!")
"hello!"
d4b0f5940a31fa5ffbc2ac2d17931d4c22d3e5ae06dbf5926167357e1f8a455d
⚡
Key Insight: Just adding "!" changed 64 out of 64 characters in the hash!
This is called the Avalanche Effect.

Key Properties of Hash Functions

Deterministic icon

Deterministic

Same input → Same output every time

Fixed length icon

Fixed Length

Output always same size

Avalanche effect icon

Avalanche Effect

Tiny change → Completely different hash

One-way icon

One-Way

Cannot get input from output

Where Hashes Are Used

Software update icon

Software Updates

How: Your phone or computer checks the hash of an update before installing it.

Why hash helps: If the file was modified, the hash changes and the system detects it.

Security icon

Password Storage

How: Websites store hash of your password, not the password itself.

Why hash helps: One-way property → attackers can't reverse it.

Blockchain icon

Blockchain

How: Each block contains hash of previous block.

Why hash helps: Avalanche effect → changing data breaks the chain.

Data transform icon

File Verification

How: Download sites show hash so you can verify file integrity.

Why hash helps: Deterministic → same file = same hash.

Network icon

Digital Signatures

How: Hash document, then encrypt hash with private key.

Why hash helps: Fixed length → easier to sign than whole document.

Did You Understand?

Make sure you understand before continuing.