Cipher Utility

Password Security: Generation and Storage Best Practices

Strong passwords for users, safe storage for developers.

Three habits that cover most of it

Use a different random password for every account, keep them in a password manager, and turn on two-factor authentication for the accounts that matter. Most account takeovers come from passwords that were reused, guessed or phished, and these three habits deal with all three. The rest of this article explains why, and what websites should do on their side.

Reuse is the biggest risk. Attackers take email and password pairs from one breached site and try them automatically on thousands of others, a technique called credential stuffing. A unique password per site means one breach stays one breach.

What makes a password strong

A strong password is one an attacker is unlikely to guess, even with fast hardware and good guessing lists. That is measured as entropy, in bits: each extra bit doubles the number of guesses needed. Entropy only applies cleanly to passwords that were generated at random. For a random password, it is the length times log2 of the number of possible characters.

The table below assumes the worst realistic case: a stolen database of fast, unsalted hashes and an attacker testing ten billion guesses per second. It shows the average time to find the password.

Password typeEntropyAverage time to guess
8 random lowercase letters~38 bitsabout 10 seconds
4 random words from a 2,048-word list (correct horse battery staple)44 bitsabout 15 minutes
12 random letters and digits~71 bitsthousands of years
6 random Diceware words (7,776-word list)~78 bitshundreds of thousands of years
16 random characters from all 94 printable ASCII characters~105 bitsfar longer than the age of the universe
20 random characters from the same set~131 bitsfar longer again

Against a site that stores passwords properly, with bcrypt or Argon2, the attacker is thousands of times slower and every row moves in your favour. You can't know how a site stores your password, so plan for the bad case.

Passwords people choose

Passwords people make up have far less entropy than they look. Cracking tools try dictionary words, names, dates, keyboard patterns and common substitutions first, so Sunshine2024!, P@ssw0rd, Qwerty123! and Fluffy2020 all fall quickly. Swapping a for @ or o for 0 adds almost nothing, because every tool tries those swaps. Personal details such as birthdays, pet names and addresses are easy to find on social media.

The fix is to let something random choose: a password generator for passwords you store in a manager, and dice for the few you have to remember.

How to create passwords

Random passwords from a generator

  1. Use a generator built on a cryptographically secure random source, such as the one in your password manager or our password generator, which runs in your browser and never sends the result anywhere.
  2. Choose at least 16 characters, and 20 or more for important accounts.
  3. Turn on upper and lower case, digits and symbols, unless a site rejects some of them.
  4. Generate a new one for every account and save it straight into the password manager.

Passphrases for passwords you must remember

You still need to remember a few passwords: the password manager's master password, and perhaps your computer login. Use a passphrase of randomly chosen words. The Diceware method uses real dice: roll five dice, look up the number in a list of 7,776 words, and repeat until you have six or more words.

tropical bicycle meadow thunder compass ancient

The randomness has to come from the dice or a generator, not from you. A phrase you made up yourself, such as a song lyric or a sentence about your life, is much weaker than its length suggests.

Where to keep your passwords

Password managers

A password manager stores all your passwords in an encrypted vault, usually with AES-256, that is unlocked by one master password. It syncs the vault across your devices and fills in logins for you. Because it only fills a password on the site it was saved for, it also protects you from many phishing pages.

Bitwarden is open source and has a free plan. 1Password is a paid service with good family and team features. KeePassXC is free, open source and keeps the vault as a local file you control. The managers built into Apple, Google, Microsoft and Firefox accounts are also a reasonable choice and far better than reusing passwords.

What to avoid

  • Plain text files, spreadsheets and notes apps: unencrypted and often synced to the cloud.
  • Emailing passwords to yourself: they stay searchable forever.
  • Sticky notes on the screen: visible to anyone nearby.
  • Remembering everything: it always ends in short, reused passwords.

A paper notebook kept at home is safe from online attackers and acceptable for a few passwords, as long as it isn't left where others can read it.

How websites should store your password

A well-run site never stores your password. It stores a hash: the output of a one-way function that can't be turned back into the password. When you log in, the site hashes what you typed with the same salt and compares the results.

Sign up:  MySecurePassword123!  →  bcrypt with a random salt  →  stored hash
Log in:   what you type         →  bcrypt with the same salt  →  compare with stored hash

The function should be slow and salted on purpose: Argon2id, bcrypt or scrypt. Try hashing a password with the bcrypt tool to see what is stored. Hashing passwords correctly covers this from the developer's side.

Signs a site stores passwords badly

  • It emails you your password, or shows it to you when you click "forgot password". A site that hashes properly can only reset it.
  • It limits passwords to a short maximum length, such as 12 or 16 characters.
  • It rejects spaces or symbols for no clear reason.

For such sites, a unique password matters even more.

Two-factor authentication

Passwords can still be phished or leaked. A second factor means a stolen password alone is not enough. The options, from strongest to weakest:

  1. Passkeys and hardware security keys such as YubiKey. They are tied to the real website's domain, so a phishing page can't use them.
  2. Authenticator apps that show a six-digit code that changes every 30 seconds. They work offline, but a convincing phishing page can still ask you for the current code.
  3. Text message codes. Better than nothing, but an attacker can take over your phone number by convincing your carrier to move it to a new SIM.
  4. Email codes. Only as safe as your email account.

Save the backup codes each service gives you when you set up 2FA, in your password manager or on paper.

Security questions

Answers to questions such as your mother's maiden name or the city you were born in are often public, have few possible answers and never change. Treat them like extra passwords: give a random answer and store it in your password manager.

Q: Mother's maiden name?
A: violet-harbor-sixty-cable   (saved in the password manager)

When to change a password

The old advice to change passwords every 90 days led to Password1, Password2, Password3. NIST's current guidance (Special Publication 800-63B) says not to force regular changes. Change a password when a service reports a breach, when you suspect someone has accessed the account, when you shared it or typed it somewhere unsafe, or when it was weak or reused. A strong, unique password protected by 2FA can stay as it is.

Getting started

  1. Choose a password manager, create a Diceware master passphrase, and turn on 2FA for the manager itself.
  2. Change the passwords for your email accounts first, then banking and payment services, then your main social media and work accounts, turning on 2FA for each.
  3. Move the rest as you log in to them over the following weeks.
  4. Delete accounts you no longer use.
  5. Let the manager's security report find reused, weak and leaked passwords, and check your email address at haveibeenpwned.com.

Common situations

  • Sharing an account with family or colleagues: use the sharing features of a family or team plan in your password manager rather than sending passwords by email or chat.
  • Losing your phone: install the password manager on more than one device, keep recovery codes offline, and set up the manager's emergency access feature if it has one.
  • Using a shared or public computer: don't save passwords in its browser, look them up on your phone instead, and log out and close the browser when you are done.
  • A service you use was breached: change that password, change it anywhere you reused it, turn on 2FA and watch the account for unusual activity.

Try it on Cipher Utility

Further reading