1 of 4

Your RightSignal

Cryptography from zero · 7 of 111 / 3

Password hashing

The concept

How a website checks your password without ever storing it

A well-built site doesn't keep your password. It keeps a hash of it: the one-way fingerprint from lesson 1. When you log in, it hashes what you typed and checks that the two fingerprints match.

Two extras make this safe. A salt is a random string made fresh for each user and stored next to their hash. And the hash is slow on purpose (bcrypt, scrypt or Argon2), so every guess costs time and memory.

Why not encrypt the passwords instead? Encryption is undone with a key, and a thief who takes the database often gets the key too. A hash has no key that undoes it, so the thief can only guess passwords and hash each guess.