Reading — step 1 of 5
Read
~1 min readWhy Passwords Need Hashing
Why Passwords Need Hashing
NEVER store passwords in plain text. When the database leaks (and it will), every account is compromised AND the same password is likely used elsewhere.
Solution: store HASHES of passwords. To verify: hash the input; compare to stored.
python
Naive: SHA-256(password). PROBLEM: too fast.
Modern GPUs compute BILLIONS of SHA-256 hashes per second. With a leaked database, an attacker tries every common password, dictionary, and rainbow tables. Most users' weak passwords crack in seconds.
Fix: use a SLOW hash. We DELIBERATELY waste CPU/memory so each guess costs more.
Targets:
- A login should take ~250ms (acceptable UX)
- An attacker brute-forcing 1B passwords takes ~1B * 250ms = 8 years (vs minutes with SHA)
The slow hash function families: bcrypt, scrypt, argon2.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…