Passwords and PINs
A password is the most familiar sign-in secret, and the easiest to copy. How a service stores and checks it decides what a stolen database gives away, and current guidance on password rules looks very different from the rules many sites still use. A PIN that unlocks a device is a different thing again.
A familiar secret
Cora Diaz signs in to the photo service with her email address and a password. The service checks the password against the one set for her account. A match shows that the person at the keyboard knows the password. It can't show whether anyone else knows it too.
That is both the strength and the weakness of a password. Cora can sign in from a borrowed laptop without carrying anything, because the secret travels in her memory. For the same reason, the secret can be copied: written down, reused on another site, guessed, or typed into a page that only looks like the photo service.
Checking a password
A password is one of the shared secrets described in Secrets and key pairs, with one useful difference. Cora sends the password at every sign-in, so the service only has to recognize it. It never needs to keep a readable copy.
When Cora sets her password, the service creates a random value called a salt for her password record. It gives the password and the salt to a password-hashing function that is deliberately slow, and stores the result together with the salt and the settings it used. Encoding and hashing showed that a hashTurning data into a short, fixed-size value called a hash, in a way that cannot be reversed and where changing one character changes the result completely. Services store password hashes instead of passwords, and signatures are made over a hash. can't be turned back into its input; a password-hashing function adds the salt and the slowness on top of that.
The salt is not a second secret. It sits beside the hash in the same record, and its job is to make each record's calculation different. If Cora and Ava happen to choose the same password, their salts differ, so their stored hashes differ, and someone who copies the records can't see that they match or test one guess against every account at once. The slowness makes each individual guess cost more time.
At sign-in, the service repeats the calculation. It runs the password Cora typed through the same function with her stored salt and settings, and compares the result with the stored hash. Nothing is decrypted, and the original password is never recovered. The password does reach the service at sign-in, over HTTPSHTTP protected by TLS, so traffic is encrypted and checked for changes while it travels. It protects the connection, but does not prove that the site at the other end is honest., which is why it must be typed only into the real sign-in page.
In simplified pseudocode, the check looks like this. Real services use an established password-hashing library rather than writing the comparison themselves:
record = load_account_password_record(account_id)
accepted = password_library.verify(record, supplied_password)
if accepted and account_is_allowed_to_sign_in:
establish_session()
else:
reject_sign_in()Because only the hash is stored, nobody at the photo service can look up Cora's password, and an administrator who sets a new one for her can't see it afterwards either. If a service can email you your old password, it kept a readable copy.
Where passwords fail
Passwords fail in a few distinct ways, and each defense helps against some of them and not others.
Online guessing happens at the sign-in page. Someone types Cora's address and tries one password after another. Every guess has to reach the photo service, so it can count failures and slow down or stop repeated attempts.
Offline guessing starts when the password database is stolen. Now guesses run on the attacker's own computers against the copied hashes, and no sign-in page is involved, so no attempt limit applies. Salts and slow hashing raise the cost of every guess, but a short or common password can still be found.
Reuse opens a path that skips the photo service entirely. If Cora used the same password at a shopping site and that site is breached, the exposed address and password work at the photo service too. Trying leaked pairs at many services is called credential stuffing, and a strong password doesn't help if it is the same everywhere.
Phishing needs no guessing at all. A page that imitates the photo service's sign-in page persuades Cora to type her password into it, and whoever runs the page receives it, however long and unique it is.
Guesses at the sign-in page
- Where it runs
- The sign-in page
- Attempt limit
- Helps
- Salted slow hash
- Not involved
- Unique password
- Helps
The hash file is stolen
- Where it runs
- The attacker's computers
- Attempt limit
- Does not apply
- Salted slow hash
- Makes each guess cost more
- Unique password
- Helps
Leaked from another site
- Where it runs
- Another site, then here
- Attempt limit
- Helps little
- Salted slow hash
- Not involved
- Unique password
- Stops it
Typed into a look-alike page
- Where it runs
- A page that imitates the photo service
- Attempt limit
- Not involved
- Salted slow hash
- Not involved
- Unique password
- Not involved
Phishing needs no guessing at all.
A password manager answers reuse: it generates a different long password for every site and fills it in, so Cora doesn't have to remember any of them. It also helps a little against phishing, because it fills a password only on the site it was saved for.
A service might be tempted to add familiar rules: at least one capital letter, a digit and a symbol, and a new password every 90 days. Those rules do little against any of these attacks. People meet them with predictable patterns such as Summer2026!, and scheduled changes push them toward small, guessable edits of the old password.
The National Institute of Standards and Technology (NIST), a United States standards body, publishes widely followed authenticationChecking evidence that someone, or some application, controls an account, such as a password or a passkey. It establishes which account is being used, not what that account may do. guidance in Special Publication 800-63B, now in its fourth revision (SP 800-63B-4). It asks for length instead of a character mix: at least 15 characters when a password is the only factor, or at least 8 when it is combined with another factor. Services should accept passphrases of at least 64 characters, allow pasting so password managers work, skip hints and security questions, and refuse new passwords that appear on lists of breached or commonly used values. They must limit consecutive failed attempts on an account. A password should change when there is evidence it was exposed, not on a schedule.
A PIN on your device
Now suppose Cora signs in with a security keyA small physical device, plugged in or held near a phone or computer, that holds credentials and uses them to prove you have it. It is an authenticator that resists phishing., a small device that holds a cryptographic key for her account. She inserts it, and it asks for a PIN. The key checks the PIN itself, and only then uses its private keyThe half of a key pair that its owner keeps to themselves and uses to create signatures or decrypt data. Anyone who obtains it can act as its owner. to sign a response. The photo service checks the signatureA value made with a private key that lets anyone holding the matching public key check that a message came from the key's holder and has not been changed. It proves origin and integrity; it does not hide the message. with the matching public keyThe half of a key pair that can be shared freely. It checks signatures made with the matching private key and can encrypt data that only that private key can decrypt. it registered. It never receives the PIN.
That changes what the PIN has to resist. It is useless without the physical key, and the key can count wrong entries and lock itself after a few, so a short PIN is enough. A password works the other way round: the service receives and checks it, and anyone who learns it can use it from anywhere. A short number that a website receives and checks for itself is a short password, whatever the form calls it.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- See what the tenant does with a passwordWatch length and breach screening refuse passwords, accept a long passphrase, see an old character-mix rule refuse it, set a unique password, and compare online limits with a stolen hash file.