LV 1 0 XP

Hashing Is Not Encryption

intermediate SEC+ 7 MIN +70 XP

What’s a hash?

A hash function turns any input into a fixed-length “fingerprint”.

"hello"  → 2cf24dba5fb0a30e26e83b2ac5b9e29e...
"hello!" → ce06092fb948d9ffac7d1a376e404b26...

Good cryptographic hashes are:

  • One-way: you can’t get the input back from the hash
  • Deterministic: the same input always gives the same hash
  • Avalanche effect: a tiny change in input completely changes the output
  • Collision-resistant: it’s infeasible to find two inputs with the same hash

Hashing vs encryption

Hashing Encryption
Reversible? ❌ No ✅ Yes, with the key
Protects Integrity Confidentiality
Examples SHA-256, SHA-3 AES, RSA

What hashes are used for

  • Integrity checks: compare a download’s hash with the published one to spot tampering
  • Digital signatures: you sign the hash of a document with your private key
  • Password storage: see below

Storing passwords the right way

Websites should never store your actual password, or even an encrypted one. They store a hash. When you log in, they hash what you typed and compare.

But plain hashes aren’t enough:

  1. Salt it: add a unique random value per user before hashing. This defeats rainbow tables (precomputed hash lists), and two users with the same password get different hashes.
  2. Make it slow: general hashes like SHA-256 are designed to be fast, so attackers can try billions of guesses per second. Password hashes like Argon2id, bcrypt and scrypt are deliberately slow and costly.

⚠️ MD5 and SHA-1 are broken for security purposes. Don’t use them for anything that matters.

⚔ QUIZ BOSS

Answer every question correctly to defeat the boss and earn 70 XP.

1. What is the key difference between hashing and encryption?
2. Why add a unique salt to each password before hashing?
3. Which is the best choice for storing user passwords?