If you store user passwords, the most important decision is not the framework or the database. It is how you turn a password into the value you save. Many tutorials still show a one-line SHA-256 or MD5 call, and that is the wrong answer for passwords. This guide explains why, and shows how to use the Password Hash Generator to compare the algorithms and to check a password against a stored hash.
What a hash is
A hash function turns any input into a fixed-length string. The same input always gives the same output, a small change gives a completely different output, and you cannot run it backwards. To check a login you hash what the user typed and compare it with the stored value; the original password is never kept.
That last sentence is true of every hash function, but it does not make them equal for passwords. The difference is speed.
Fast hashes are the problem
MD5 and the SHA family were designed to check that data was not changed: file checksums, signatures. For that job, being fast is a virtue. For passwords it is a disaster. If your database leaks, an attacker can try guesses against the hashes offline, and a fast hash lets them try enormous numbers of guesses per second. Common passwords and short ones fall quickly. Precomputed tables of hashes (rainbow tables) make it even faster when no salt is used.
A password hash must be deliberately slow, must include a unique random value (a salt) for every password, and must let you make it slower later as computers get faster. bcrypt does all three.
The algorithms in the tool
| Algorithm | Output | Use for passwords? | Good for |
|---|---|---|---|
| MD5 | 32 hex characters | No | Non-security checksums, cache keys |
| SHA-1 | 40 hex characters | No | Legacy systems only; not recommended for new work |
| SHA-256 | 64 hex characters | No | File integrity, signatures, general hashing |
| SHA-512 | 128 hex characters | No | The same, with a longer output |
| bcrypt | 60 characters starting with $2a$, $2b$ or $2y$ | Yes | Storing passwords |
For new systems, bcrypt, scrypt and Argon2 are the accepted choices; the tool offers bcrypt. Follow current guidance from OWASP for the exact settings of each.
Salt and rounds in bcrypt
bcrypt creates a new random salt for every hash and stores it inside the result, so two users with the same password get different hashes, and tables prepared in advance are useless. You do not manage the salt yourself.
The salt rounds (the work factor) set how much work each hash takes. Each increase of one doubles the time. The tool allows 4 to 15 and starts at 12. Higher is safer and slower. Production systems usually use 12 or more, tuned so that one login takes a noticeable but acceptable fraction of a second on your server. Too low is weak; too high lets anyone make your login endpoint hog the processor. Re-measure from time to time, raise the number as hardware improves, and re-hash passwords at the next login of each user.
Step by step in the tool
- Pick the algorithm. The cards show a short note: bcrypt is marked as best for password hashing.
- Type a test password. The hash is made locally, in your browser. bcrypt runs in a background worker with a progress bar, because high rounds take seconds.
- Copy the hash, or click an entry in the history list to copy it. Each entry shows the algorithm, the time and the hash.
- To check a password, use the verification section: enter the password and a hash. The tool recognises the algorithm from the format and says whether they match. For bcrypt it uses the built-in compare; for the others it hashes the input again and compares.
Try the same password with MD5 and with bcrypt at 12 rounds. The MD5 result appears immediately and is always the same; the bcrypt result takes a moment and is different each time you generate it. That difference is the whole point.
Is it safe to use real passwords here?
Hashing happens in your browser and nothing is sent to TabShed. Even so, treat the page as a testing tool: use sample passwords while learning and testing, and generate real production hashes on your server, in code, where passwords never go through a browser tab or a clipboard history.
Best practices checklist
- Never store plain text or reversible encryption of passwords.
- Never use MD5, SHA-1 or a bare SHA-2 hash for passwords. If you must use a fast hash for some reason, add a unique salt, and then reconsider.
- Use a maintained library; do not write your own cryptography.
- Limit login attempts, and do not tell an attacker whether it was the user name or the password that was wrong.
- Allow long passwords. bcrypt itself looks only at the first 72 bytes of the input, so very long inputs are cut by the algorithm; check what your library does.
- Generate strong test passwords with the Password Generator, and see how long a password should be.
When MD5 and SHA are fine
For file checksums, cache keys, ETags, deduplication and the signature part of protocols, fast hashes are the right tool. Do not use MD5 where an attacker could craft collisions, such as certificates and signatures. Encoding such as Base64 is not hashing at all; see the Base64 tool.
Frequently asked questions
Why is the bcrypt hash different each time?
A new random salt is used each time. Verification still works, because the salt is stored inside the hash.
What do the hash formats look like?
MD5 is 32 characters, SHA-1 40, SHA-256 64 and SHA-512 128. bcrypt hashes begin with $2a$, $2b$ or $2y$, followed by the rounds.
Can a hash be decrypted?
No. Attackers guess passwords and compare the results; slow hashing makes that costly.
How many rounds should I use?
12 or more in production, tuned to your server.