sh0p.exampleshop.exampleuser–salt–hash–passkey–1import hashlib, hmac, os2def slow(pw, salt):3 return hashlib.pbkdf2_hmac(4 "sha256", pw, salt, 600_000)5salt = os.urandom(16)6saved = slow(b"plum-ferry-1979", salt)7typed = slow(b"plum-ferry-1979", salt)8print(hmac.compare_digest(saved, typed))→ True
Back: the look-alike site, Ana at her laptop, the real site shop.example and Ana's saved recordFront: the Python that salts, hashes and compares, and Ana's phoneTokens: the passphrase, a stolen record, a 6-digit code, a public key, a challenge and its signatureAna signs up at shop.example. The site saves a random salt and a slow, one-way hash of her passphrase, never the passphrase itself, and signs her in by comparing hashes. A leak gives away only salts and hashes. An authenticator code adds a second factor but can be typed into a look-alike site. A passkey leaves only a public key on the site and signs a fresh challenge, and only for shop.example.

Storing a password

  1. Authentication means proving you are who you say you are before a site lets you in. Each proof is a factor. There are three kinds: something you know (a password), something you have (a phone) and something you are (a fingerprint).

When passwords leak

MFA and passkeys

What happens

;; step 1/12 · factors
authentication   proving who you are
factor           one kind of proof
  know           a password or PIN
  have           a phone, a security key
  are            a fingerprint, a face

The salt and hash shown are real outputs for one fixed example salt. os.urandom gives a new salt every run, so your hash will differ. Real sites also add rate limits and checks on sign-in. Many passkeys are synced between your own devices by your phone maker or password manager, encrypted. Either way the private key is never sent to the website. Unlocking with a fingerprint or PIN makes a passkey two factors in one step.