BobWork Vault
Security basics

Password Hashes Explained: How Sites Store Passwords Without Knowing Them

A password hash is a fixed-length scrambled fingerprint of a password, made by a one-way function that cannot be reversed. Websites store the hash instead of the password, so a stolen database does not directly reveal passwords. Good sites add a random salt and use a deliberately slow algorithm such as bcrypt, PBKDF2 or Argon2.

By the BobWork team · · 5 min read

Add to Chrome — freeCreate a free account

What are password hashes?

A password hash is the output of a one-way mathematical function that turns any password into a fixed-length string of characters. The same input always gives the same output, but you cannot run the function backwards to get the password out.

Think of it as a fingerprint. A fingerprint identifies a person, but you cannot rebuild the person from it. In the same way, a hash lets a website recognise your password without keeping the password itself.

A short example of how a fast, general-purpose hash behaves (the exact characters do not matter, the behaviour does):

  • The word sunshine always produces the same long string.
  • Changing one letter, sunshine1, produces a completely different string.
  • Every output is the same length, whether the input is 4 characters or 400.

Why do websites store password hashes instead of passwords?

Websites store password hashes so that nobody who reads the database, including the site's own staff or an attacker, can simply copy out everyone's passwords.

Here is the flow when you sign in to a site that stores hashes:

  1. You create an account and type a password.
  2. The site runs the password through a hash function and saves only the result.
  3. Next time you sign in, the site hashes what you typed and compares it with the saved hash.
  4. If the two match, you are in. The original password is never stored.

This is why a properly built site can never email you your old password. It does not have it. If a site can send you your current password in plain text, that is a warning sign. The standard for this is covered by guidance such as NIST SP 800-63B and the OWASP Password Storage Cheat Sheet, which both expect passwords to be stored as salted, slow hashes.

What is the difference between hashing and encryption?

Encryption is reversible with a key, while hashing is one-way and cannot be reversed at all.

With encryption you lock data so that someone holding the right key can unlock it later. That is what you want for things you need to read again, such as the passwords stored inside a password manager. With hashing there is no key and no way back, which is what you want for a site that only needs to check whether you typed the right password.

HashingEncryption
Reversible?NoYes, with the key
Uses a key?No (a salt is not a key)Yes
Output lengthFixedGrows with the data
Typical useChecking a password at sign-inStoring data you must read again

For the encryption side in more depth, see password encryption explained.

If hashes cannot be reversed, how do attackers crack them?

Attackers do not reverse a hash, they guess: they hash millions of likely passwords and look for a match with the stolen hash.

Because the same password always gives the same hash, a guess that matches the stolen value reveals the original password. Attackers start with lists of common passwords, leaked passwords from past breaches and simple variations such as Password1!. This is why a short or common password falls quickly even when it is hashed, and why a long, unique one holds up. Our guide to what makes a strong password covers how to pick one.

Attackers can also use precomputed tables, sometimes called rainbow tables, which list the hashes of many common passwords in advance. Salts exist to defeat exactly this.

What is a salt in password hashing?

A salt is a random value added to each password before it is hashed, so two people with the same password end up with different hashes.

The site stores the salt next to the hash. It is not secret. Its job is to make attacks expensive in two ways:

  • No shared shortcuts. A precomputed table of hashes is useless, because every account used a different salt.
  • No spotting duplicates. If a thousand users picked the same password, an attacker cannot see that from the database, because all thousand hashes look different.

An attacker who steals the database still can try guesses, but must run them against each account separately. That is a huge multiplier in work.

Why are bcrypt, PBKDF2 and Argon2 slow on purpose?

Password hash algorithms are slow on purpose because the slower each guess is, the fewer guesses an attacker can make per second.

General-purpose hashes such as SHA-256 were designed to be fast, which is great for checking a file but poor for protecting passwords, since a fast hash lets an attacker try enormous numbers of guesses. Password-specific algorithms add a tunable cost so that one guess takes noticeable work. A real user signing in only does that work once, so they never notice. An attacker doing billions of guesses feels every bit of it.

AlgorithmHow it slows guessingWhere you will see it
PBKDF2Repeats the hash many times (the iteration count)Widely supported, often used to stretch a master password into a key
bcryptBuilt-in adjustable work factorLong-standing choice for website logins
Argon2Also needs a lot of memory, which hurts attackers using specialised hardwareNewer; the OWASP Password Storage Cheat Sheet lists Argon2id as its first choice

The cost is meant to rise over time as computers get faster. A setting that was sensible years ago can be too low today, which is why recommended iteration counts keep going up.

Do password managers use hashing too?

Yes, password managers use slow hashing, but mostly to turn your master password into an encryption key rather than to store it for sign-in checks.

The master password is the one thing the manager must protect most, so it is stretched with a slow function before anything else happens. BobWork Vault, for example, stretches the master password with PBKDF2-SHA256 at 600,000 iterations, then derives from it an encryption key and a separate sign-in proof. Everything in the vault is encrypted in your browser, and the server stores only ciphertext. The details are in zero-knowledge encryption explained and on the security page.

The takeaway for you is the same as for any site: the slow hash buys time, but a strong, long master password is what the time is protecting. Hashing makes guessing slower, it does not make a weak password strong.

What can you do to protect yourself from a hash leak?

You cannot control how a site stores your password, but you can make sure a leaked hash is worth nothing to the attacker.

  1. Use a unique password for every account. If one site stores weak hashes and leaks them, a cracked password cannot open your other accounts.
  2. Make passwords long and random. A generated password of 16 or more characters is not in any guess list.
  3. Turn on two-factor authentication. A cracked password alone then is not enough to sign in. See what 2FA is.
  4. Check for known breaches. Services such as Have I Been Pwned tell you if your email appeared in a leak.
  5. Change the password when a site is breached. Follow the steps in the data breach password response checklist.

Doing all of this by hand for dozens of accounts is unrealistic, which is the job a free password manager does: it generates and remembers a unique password for each login.

How can you tell if a site stores passwords safely?

You usually cannot see how a site stores passwords, but a few signs suggest it does not.

  • It emails you your existing password after a reset request.
  • It limits you to a short maximum length or forbids symbols, which can hint at poor storage.
  • It has had past breaches where passwords were exposed in plain text.

None of these proves anything on its own, so the safest assumption is that any site could leak. That is the reason to keep every password unique.

Try BobWork Vault — free for your whole team

BobWork Vault is a free, zero-knowledge password manager for teams, made by BobWork (BobOffice, LLC). Shared folders, login-only access, 2FA codes and guided offboarding, end-to-end encrypted. Add it to Chrome or create a free account.

Keep reading

More: free password manager · free team password manager · free company password manager · company password manager · password management software · how to share passwords with teammates · compare password managers

Questions

Can a password hash be reversed?

No. A hash is a one-way function, so there is no direct way to turn it back into the password. Attackers instead guess passwords, hash each guess and compare it to the stolen hash, which is why weak passwords still get cracked.

Is hashing the same as encryption?

No. Encryption is reversible with a key and is used for data you need to read again. Hashing is one-way and has no key, so it is used to check a password without storing it.

Is it safe if a website stores my password as a hash?

It is safer than plain text, but not a guarantee. Strong, slow, salted hashing protects well against guessing for long passwords, while weak or unsalted hashes can be cracked quickly. Use a unique password per site either way.

Why is MD5 or SHA-256 not good enough for passwords?

They are fast by design, which lets an attacker test huge numbers of guesses per second. Password-specific algorithms such as bcrypt, PBKDF2 and Argon2 add deliberate cost to slow that down.

What is the best password hashing algorithm?

The OWASP Password Storage Cheat Sheet lists Argon2id as its first choice, with bcrypt and PBKDF2 as accepted alternatives where Argon2 is not available. The settings matter as much as the name.

Does a salt need to be secret?

No. A salt is stored next to the hash and is not a secret. It works by making every hash unique, so precomputed tables and duplicate-spotting do not work.