Lazo Lab Sign up

App 3: Password Generator & Checker / Build the password tool

Lesson 9 of 10

Hashing: how sites store passwords

Good websites never store your password, only a slow salted hash of it. Try hashlib to see how one tiny change gives a totally different hash.

Key points

  • Hashes are one-way
  • Real sites use slow hashes like bcrypt or Argon2
  • Same input, same hash; tiny change, new hash
import hashlib
for pw in ["hello", "hellp"]:
    print(pw, hashlib.sha256(pw.encode()).hexdigest()[:16])

Your turn

Add a menu option that shows the SHA-256 hash of some text, and notice how it changes.

Watch a video on thisOpens YouTube search results for “Hashing: how sites store passwords” in a new tab

Quiz · +10 XP

Can you turn a SHA-256 hash back into the password?

Log in to save progress and earn XP.