Wirebook › Lesson 15 of 18
How does a website check your password without keeping it?
You type your password, and the website lets you in. So the website must keep a copy of your password somewhere… right? A careful one doesn't. It keeps something cleverer: a scrambled fingerprint it can check against but can't turn back into your password. Here are three pretend websites storing the same accounts, a thief who steals all three, and a meter that shows how long your password would last.
How can a website check a password it doesn't keep?
When you make an account, a careful website runs your password through a hash: a recipe that turns any text into a long jumble of letters and numbers, a fingerprint. The same password always makes the same fingerprint, but you can't run the recipe backwards. The website saves only the fingerprint.
When you log in, it runs what you typed through the same recipe and compares the two fingerprints. If they match, you typed the right password. The website never needed to remember the password itself, and nobody who works there can read it. That's why a good site can't "email you your password" when you forget it; it can only let you set a new one.
What are salt and slow fingerprints for?
Fingerprints alone aren't enough. A thief who steals Site B's list can't reverse the fingerprints, but they can guess: take a list of favourite passwords ("123456", "sunshine", "pizza2015"…), fingerprint each one and look for matches. Plain fingerprints are so fast to make that one gaming graphics card can try around ten billion guesses a second. Worse, two people with the same password get the same fingerprint, so one lucky guess opens both.
Careful sites add a salt: a few random characters, different for every person, mixed in before the fingerprint is made. Now Otter's and Badger's "sunshine" fingerprints look completely different, and the thief has to start over for every single person. Then they make the recipe deliberately slow, repeating it thousands of times (recipes called PBKDF2, bcrypt, scrypt and Argon2). You don't notice a quarter of a second when you log in once, but a thief making billions of guesses does.
Salt and slowness buy time. They don't make "sunshine" safe, because it's near the top of every guess list. That part is up to you.
Long and random beats clever
A thief doesn't try letters one by one. They try the things people actually choose: names, pets, football teams, "password1", a word with a year and an exclamation mark on the end. Swapping "o" for "0" doesn't fool them either; their lists already include those swaps. What really slows a thief is length chosen at random.
That's why a passphrase works so well: five or six random words, like the ones the dice button makes. Each extra random word multiplies the guessing by over a thousand, and a silly picture ("a blade, a diner, a nutty radar") is easier to remember than "Tr0ub4dor&3". Better still, let a password manager invent a different long password for every site and remember them for you; then you only need one strong passphrase.