Skip to content

Hashing a password

Level: 201 · for anyone who stores a login

Stub — an outline, not a lesson. There is no runnable example behind this page yet, so nothing on it has been through the check that backs every other claim in this library. The bullets below are the questions the finished page has to answer.

One line: The one place in cryptography where you deliberately choose the slowest function you can afford.

The questions this page has to answer

  • Why is a fast hash exactly wrong here, and what does a GPU do to SHA-256 per second?
  • What is a salt for, what is it not for, and why does it not need to be secret?
  • What is a pepper, and what different threat does it address?
  • PBKDF2, bcrypt, scrypt, Argon2id: what each one makes expensive, and why memory-hardness beat iteration count.
  • hashlib.scrypt and hashlib.pbkdf2_hmac are in the standard library — what parameters, and how do you pick them?

See also