← Teacher guide

Hashes and salt

Students sign in against a stored hash, see one letter change the whole hash, crack an unsalted stolen list by hashing common guesses, then add a salt, and sort what a hash is for against what encryption is for (AC9TDI10K01 node 4, first half; Public and private keys is the second).

Security and privacy · How systems are kept safe · about 45 minutes · Open the student lesson

Classroom resources

Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Try 6 min · Worked example 12 min · Vary 10 min · Practise and Make 12 min

Before class

Try the boards yourself. The hash is real SHA-256 (shown short); the passwords in the lesson are practice ones. Tell students never to type a real password into any board.

The kit's typical width: hashing secures stored passwords; public key cryptography (next lesson) secures data in transit; they address different threats, and mixing them up is why this node is a hinge. Split from Hashes and keys on 25 Oct so each gets a full lesson. Simplifications: real sites use slow hashes built for passwords (bcrypt, Argon2) and store the salt beside the hash.

Links: Secret messages' key sharing (agreeing a key in public) is the other half of how HTTPS starts.

Running the lesson

  1. Predict: students who chose "your password" assume sites keep it.
  2. Try: count how many digits changed for one letter.
  3. Worked example: ask why the same password must always give the same hash.
  4. Vary: ask why the thief can crack Ana and Ben without reversing anything; then what the salt changes.
  5. Make: remind students not to type a real password; it is a made-up passphrase.

In class

On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.

The hard part (on purpose)

Hashing is one-way, which runs against intuition, and students call it encryption. Use the meat grinder (you can't un-mince) as the anchor, and the sort in Practise to pull hash and encryption apart.

When students get stuck

What you will seeA question to askThe fix
A student says the site turns the hash back (Sam's mistake).Why does the site send a reset link instead of your password?It can't reverse the hash.
A student calls hashing encryption.Could anyone, with any key, turn the hash back into maple?Encryption is undone with a key; a hash can't be undone at all.

Answers to the checks

  1. a stolen list: A website is hacked and its list of passwords is stolen. If the site did its job properly, what do the attackers find for your account?
    A hash. The site never kept the password: it stores the hash, and at sign-in hashes what you type and compares.
  2. Try: sign in with a hash: The site stores only Kai's hash. Type Kai's password (maple). Then change one letter to a capital. What happens to the hash?

    maple matches the stored hash; Maple gives a completely different one. The site can check you without ever storing the password.
  3. Two tools: Why can a site check your password without storing it?
    The same password always gives the same hash
    It compares hashes: hash what is typed; if it equals the stored hash, the password was right.
  4. Find the mistake: Sam explains how Forgot password works. Click the line where it first goes wrong.
    line 3
    Line 3: a hash can't be turned back. That is why sites send a reset link instead; a site that emails you your old password is storing it, which is a warning sign.
  5. Same password, same hash: Ana and Ben both use maple. With no salt, a stolen list shows the same hash twice. What does that tell a thief?
    They share a password: crack one, crack both
    Same password, same hash. A salt (a few random characters per person, added before hashing) gives Ana and Ben different hashes.
  6. Crack the list: This list was stolen from a site with no salt. Type passwords people often pick, one at a time, and watch for a row lighting up.

    Same password, same hash: Ana and Ben both use maple, and Cara's sunshine1 lights up too. Dev's long passphrase never does: nobody would guess it.
  7. Salt: Type maple, then switch on the salt. Ana and Ben both use maple. Are their hashes the same?

    Different salts, different hashes: a list of pre-hashed common passwords no longer matches, and nobody can tell that two people share a password.
  8. Emailed passwords: A site emails you your old password when you click Forgot password. What does that tell you?
    It stores your password, not a hash: a bad sign
    A hash can't be reversed, so a well-built site can only send a reset link.
  9. Passphrases: Why are long passphrases safer even when sites store hashes?
    A long unusual one isn't on guess lists
    Attackers hash lists of common passwords and compare, so guessing still works on common passwords. Length and unusual words defeat the guess lists.
  10. Hash or encryption?: Which tool fits? Sort each one.
    A site keeps your password so it can check it next time → A hash; Your card number on its way to an online shop → Encryption; Checking a downloaded app is exactly the file its maker published → A hash; A private message to a friend across the internet → Encryption; A news headline anyone can read → Neither
    Hash what only needs checking; encrypt what someone has to read again. A hash is not encryption: it can't be undone, even with a key.
  11. Review: access: Review: which is authorisation?
    Only teachers may change marks
    Authorisation is what you may do once signed in.
  12. a strong passphrase: Make up (don't use a real one) a passphrase of at least four unrelated words and 20 characters. Watch its hash.

    Long and unusual: not on any list of common passwords, and still easy to remember.

Solutions

One possible solution for each task. Other correct programs are fine.

Vary: crack a list, then salt it › Crack the list

Open task: any program that does what the step asks.

Vary: crack a list, then salt it › Salt

Open task: any program that does what the step asks.

a strong passphrase

Open task: any program that does what the step asks.

Stretch and support

Stretch: Why do security experts recommend a password manager? What does it change about using the same password on several sites?

Support: Two cards: Only needs checking → hash (one way). Has to be read again → encryption (a key undoes it).

Exit ticket

Why can't attackers read passwords from a list of hashes, and what can they still do? What does a salt stop?

A hash can't be reversed, but common passwords can be guessed: hash the guess, compare. A salt makes the same password hash differently for each person, so one guess no longer cracks everyone who chose it.

What each step is for

Where it leads

Next: Public and private keys (protecting data while it travels).