Overview
Hashing is the one-way transformation at the core of secure password storage. Understanding it — and why the right kind of hash matters — is essential. This lesson covers hashing for passwords.
Learning objectives
- Define cryptographic hashing and its one-way property.
- Explain why password hashing needs slow/adaptive functions.
- Distinguish suitable from unsuitable hash functions.
Core concept
A cryptographic hash is a one-way function: it maps input to a fixed-size digest that cannot feasibly be reversed to recover the input. Passwords are stored as hashes and verified by hashing the submitted password and comparing. Crucially, not all hashes are suitable for passwords: general-purpose fast hashes (e.g. MD5, SHA-256) are designed for speed, which helps attackers brute-force. Password storage requires slow/adaptive hashes — bcrypt, scrypt, Argon2, PBKDF2 — deliberately expensive to compute, slowing cracking.
How it works
Because a hash is one-way, the stored digest does not reveal the password, and login works by comparing hashes rather than storing the secret. But if the hashes are stolen (a breach), attackers try to crack them by hashing guesses and comparing. Fast hashes let attackers try enormous numbers of guesses per second, so weak/reused passwords fall quickly. Slow/adaptive hashes intentionally take significant compute per guess (and are tunable to stay slow as hardware improves), drastically reducing crack speed and buying protection. Choosing a slow, purpose-built password hash is therefore essential.
Practical example
A credential store using SHA-256 (a fast hash) for passwords is weak: if breached, attackers can test billions of guesses quickly, cracking many passwords. Migrating to Argon2 or bcrypt (slow, adaptive) means each guess is far more expensive, so cracking the same stolen hashes becomes vastly slower — strong passwords stay safe and users have time to respond. The assessment finding would be "uses a fast general-purpose hash for passwords; use an adaptive password hash instead."
Cybersecurity relevance
The choice of hash function is decisive for breach resilience: fast general-purpose hashes enable mass cracking, while slow adaptive hashes (bcrypt/scrypt/Argon2/PBKDF2) strongly resist it. Using a fast hash (or, worse, an unsalted one — next lesson) for passwords is a common, serious finding in assessments and a frequent cause of large-scale credential compromise after breaches. This reinforces the web-security storage guidance. The lesson is defensive: store passwords with a slow, adaptive, salted hash.
Common mistakes
- Using fast general-purpose hashes (MD5/SHA-256) for passwords.
- Assuming any hashing is sufficient, ignoring the speed/adaptivity requirement.
- Rolling a custom hashing scheme instead of a vetted adaptive password hash.
Key takeaways
- A cryptographic hash is one-way; passwords are stored and verified as hashes, not recovered.
- Password hashing must use slow/adaptive functions (bcrypt, scrypt, Argon2, PBKDF2), not fast general-purpose hashes (MD5/SHA-256), because speed aids brute-forcing.
- Slow adaptive hashing strongly resists cracking of stolen hashes; using a fast hash is a common, serious finding.
Check your understanding
- Why are fast general-purpose hashes unsuitable for storing passwords?
- What kinds of hash functions are appropriate for password storage, and why?

