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




