Why should a password hash take time and memory to compute?

Password hashing can make repeated checks expensive. The cost still has to work for people signing in normally.

The example below compares changing the time and memory costs separately.

Time and memory do different jobs

A password verification checks one submitted password against the stored result for that account. Cost settings control the work the password hashing scheme asks for. In the model, increasing time from one tick to four makes one check take four times as long. With eight memory slots total, checks using two slots fit four at once. Checks using four slots fit two at once. In this model, raising memory per check reduces parallel capacity while the delay for a single check stays the same.

Memory-hard password hashing is designed to make it expensive to avoid using substantial working memory. Argon2id is one example with settings for memory and time. The board keeps those effects separate. It counts how many checks could finish in four ticks if every allowed check position stays busy. On real systems, memory use can also affect runtime, and how much work fits at once depends on the hardware. The slots and ticks describe the model. See RFC 9106’s description of Argon2.

The salt from Lesson 4.6 separates the work across records. The cost settings make each check take work. A person signing in usually waits for one verification. Someone repeatedly checking guesses has to pay the cost again for each check. A setting should make repeated work more expensive while leaving a normal sign-in practical, including when several people sign in at once.

Check your understanding

Set the model to four ticks and four slots per check. How many checks fit at once? Why might a useful setting also need to keep normal sign-in delays short?

Show the answer

Two checks fit at once, so another person could have to wait. Every normal sign-in pays the time cost too. The service needs a delay users can tolerate and enough resources to handle legitimate requests.

What each check needs

What reference or stored value does each task rely on? Which task benefits from a deliberate cost per guess, and why?

Show the comparison
Three jobs for hashing
TaskWhat it relies on
Check a downloadA trusted fingerprint for the expected file.
Check a Merkle leafA trusted root and the proof for that leaf.
Store passwordsA distinct salt per record and a password hashing scheme with a deliberate cost per guess.

In a download check or a Merkle proof, you have an item to check against a trusted value. Password storage has to account for repeated guesses at an unknown password.

The next chapter starts by publishing hashes of two secrets for a vote signed on paper.