liveBook · Manning

Password hashing

As explained in Real-World Cryptography

The use of a deliberately configured password-processing function to derive values suitable for storing and verifying passwords without retaining the passwords themselves.

A website should not keep users’ passwords in cleartext: one database breach could expose credentials that users reuse elsewhere. Password hashing stores a derived digest instead, limiting how long the server handles the original password. section 2.6 section 11.2

A typical password-verification flow is:

  • Receive the password during registration or login. section 2.6
  • Run it through a password-hashing function and discard the password. section 2.6
  • Store the resulting digest rather than the password. section 2.6
  • Hash the login attempt and compare its digest with the stored value; matching values authenticate the user. section 2.6

Hashing improves a database breach but does not make passwords invulnerable. Attackers can test guesses through brute force or exhaustive search, while an intruder inside the server may continue stealing passwords during login. Password hashing is therefore one layer of defense in depth, not a complete authentication system. section 2.6 section 11.2

A safer registration and login design

At registration, store the password-hash digest. At login, hash the supplied password, compare the result, and then authenticate only when the values match. Argon2 is identified as a standardized password-hashing algorithm for this purpose. section 2.6 section 11.2

Figure 2.18 In this chapter, you saw four types of hash functions: (1) the normal kind that provide a unique random-looking identifier for arbitrary-length inputs; (2) extendable output functions that are similar but provide an arbitrary-length output; (3) tuple hash functions that unambiguously list hash values; and (4) password-hashing functions that can’t be easily optimized in order to store passwords safely.

Places password-hashing functions among hash-function types designed to resist easy optimization for safer password storage. section 2.6

How Real-World Cryptography covers it

How deep it goes
Explains the storage and verification flow, brute-force risk, and residual server compromise, but stops short of implementation detail.
Examples
Uses website registration and login, cleartext databases, stolen password databases, digest comparison, and Argon2.
What it assumes
Assumes familiarity with hash functions and basic website registration and login, while introducing password storage from the cleartext problem.
What you can do after
Apply it via Argon2 by storing password hashes and comparing hashes during login instead of retaining passwords.
How it connects
Connects hash functions, user authentication, database breaches, brute-force attacks, and defense in depth.

Also explained in

Compare how 5 books explain password hashing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Real-World Cryptography. The section links point to the parts of the book it draws on.