Intermediate

Implement a Password Hashing Scheme

Hash and verify passwords correctly with Argon2id, understand exactly why fast general-purpose hashes like SHA-256 are the wrong tool for this job, and build a login flow with a proper rehash-on-login migration path.

~2.5h
0 / 7 steps
🚀
Intro

Why a hash function you already know is the wrong tool here

Prerequisites: Completion of Hashing and Digital Signatures; Python 3.10+; basic familiarity with sqlite3 (standard library, no install needed).

Verified against the OWASP Password Storage Cheat Sheet and the argon2-cffi documentation (25.1.0, current stable on PyPI), July 2026. OWASP's current cheat sheet lists Argon2id as the first-choice algorithm, with a minimum acceptable configuration of 19 MiB memory / 2 iterations / 1-degree parallelism, and a higher-memory alternative of 46 MiB memory / 1 iteration / 1-degree parallelism; bcrypt (work factor 10+, practically 12-14 in 2026) and PBKDF2-HMAC-SHA256 (600,000+ iterations, for FIPS-140 environments specifically) remain listed as acceptable fallbacks. This project uses argon2-cffi's library defaults (time_cost=3, memory_cost=65536 KiB / 64 MiB, parallelism=4) as the starting point, which sit comfortably above OWASP's stated minimum, and shows how to benchmark and adjust from there.

In the Hashing and Digital Signatures project, fast was a feature — you want to hash a large file or verify a signature quickly. For passwords, fast is a liability: SHA-256 is designed to compute millions of hashes per second on ordinary hardware, and a modern GPU can attempt tens of billions of SHA-256 guesses per second. If your database of SHA256(password) values leaks, an attacker with a GPU rental and a common password list can crack a large fraction of them before you've finished reading the breach notification.

Password hashing needs the opposite property: deliberately, tunably slow, and ideally memory-hard (requiring a large, fixed amount of RAM per guess, which specifically blunts GPU and ASIC attacks, since those devices have abundant compute but comparatively little memory per parallel unit). Argon2id — winner of the 2015 Password Hashing Competition and OWASP's current top recommendation — is built exactly for this.

🔨

Install argon2-cffi and hash your first password

🔨

Tune the parameters — and prove your choice with a benchmark

🔨

Login flow with rehash-on-login

🔨

Defense in depth: hashing parameters aren't the whole story

🎯
Secret Mission

Secret Mission: build an auth module with a live cracking-speed comparison

🧹
Wrap Up

Before You Go

Pro

Test what you just learned

Self-testing is one of the best ways to retain new skills. Unlock project quizzes to check your understanding.

Log in to unlock