Course contentsShow
← Computer Science
Lesson 2505 of 2,87256. Authentication and AuthorizationFree lesson

Cryptographic Hash Functions for Passwords

How one-way hash functions protect passwords and why simple hashing alone is insufficient.

Cryptographic Hash Functions for Passwords

What You'll Learn

You'll discover how one-way hash functions protect stored passwords and why simple hashing alone isn't enough to secure them.

The Core Protection Mechanism

When a system stores your password, it shouldn't keep the actual password text—that would be a disaster if the database is compromised. Instead, it applies a cryptographic hash function to transform your password into a fixed-size, irreversible string of characters.

Remember from earlier lessons that hash functions have preimage resistance (one-wayness)—you can't reverse the hash back to the original password. This means even if attackers steal the password database, they can't simply "decrypt" your password.

How It Works

When you register:

  1. You submit password: myS3cretP@ss
  2. Server computes: hash("myS3cretP@ss") → stores the hash only
  3. Database contains: 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8

When you log in:

  1. You submit password: myS3cretP@ss
  2. Server computes: hash("myS3cretP@ss")
  3. Server compares this new hash with the stored hash
  4. If they match—you're authenticated!

Why Simple Hashing Isn't Enough

Here's the problem: if two users have the same password, they'll have identical hashes. Attackers can exploit this with rainbow tables—precomputed databases mapping common passwords to their hashes. They simply look up your hash and instantly know your password was password123.

Additionally, fast hash functions like SHA-256 allow attackers to compute billions of hashes per second, making brute-force attacks frighteningly efficient against common passwords.

Key Takeaway: While cryptographic hash functions provide one-way transformation essential for password protection, simple hashing is vulnerable to rainbow table and brute-force attacks—requiring additional defenses like salting and specialized slow hash functions.