You are signed in. Close

You are signed out. Close

Thank you. Your subscription has started. Close

Thank you. You will get an email when a new comic comes out. Close

We could not confirm your payment. If you paid, use the link "Sign in" at the bottom of the page. Close

Something went wrong on our side. Please try again in a moment. Close

Previous episode Plain-text passwords: why a website should not keep your password as you typed it

How passwords and logins work: why a website should not know your password

Password hashing: how a website checks your password without keeping it

You click "forgot password" on a good website. It never sends your old password back, because it does not have it. Yet it checks every password you type. How?

  1. 1 Miva's website runs your password through a hash function, drawn here as a grinder. Out comes a string of letters and digits, a kind of fingerprint of your password. It is called a hash.sunflower7hash function81580afc7bfcthe hash

    Miva's website runs your password through a hash function, drawn here as a grinder. Out comes a string of letters and digits, a kind of fingerprint of your password. It is called a hash.

  2. 2 Put sunflower7 in a thousand times, on any computer, and the same hash comes out every time.sunflower781580afc7bfcsunflower781580afc7bfcsame password, same hash

    Put sunflower7 in a thousand times, on any computer, and the same hash comes out every time.

  3. 3 Change one character, and the hash has nothing in common with the first one. It gives no hint of how close you were.sunflower84725a7272bfesunflower7 gave:81580afc7bfc

    Change one character, and the hash has nothing in common with the first one. It gives no hint of how close you were.

  4. 4 And the grinder turns one way only. Nobody can feed it the hash and get sunflower7 back out.81580afc7bfcno way back

    And the grinder turns one way only. Nobody can feed it the hash and get sunflower7 back out.

  5. 5 So on the day you sign up, the website keeps only the hash. Your password itself is thrown away.climbwall.example: membersemailhashyou@mail.example81580afc7bfclea@mail.example8d969eef6ecasam@mail.example81a103d766desunflower7thrown away

    So on the day you sign up, the website keeps only the hash. Your password itself is thrown away.

  6. 6 A week later, you type your password again. The website grinds it the same way and compares the two hashes. They match, so you typed the right password, and you are in. Miva never needs to know what it was.sunflower781580afc7bfckept since sign-up:81580afc7bfcWelcome back!

    A week later, you type your password again. The website grinds it the same way and compares the two hashes. They match, so you typed the right password, and you are in. Miva never needs to know what it was.

  7. 7 Now the gym keeps 5,000 hashes and not one password. One night, Rono finds a way into the server and copies the whole list.the gym's server5,000 hashesRono

    Now the gym keeps 5,000 hashes and not one password. One night, Rono finds a way into the server and copies the whole list.

  8. Quick check

    Quick check.You forget yourpassword and askthe gym for it.Can Miva tell youwhat it was?

    Quick check.

    Show the answer

    No. The website keeps only the hash, and there is no way back from a hash to the password. It can only let you choose a new one.

  9. Go further

    One name worth knowing.SHA-256a common hash function,the one that made thehashes here. A whole hashhas 64 characters: theseshow the first 12

    One name worth knowing.

Next episode Password cracking: why a stolen list of hashes still gives passwords away

Share this comic

More comics