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:
- You submit password:
myS3cretP@ss - Server computes:
hash("myS3cretP@ss")→ stores the hash only - Database contains:
5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
When you log in:
- You submit password:
myS3cretP@ss - Server computes:
hash("myS3cretP@ss") - Server compares this new hash with the stored hash
- 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.