What is a hash?
A hash is a short, fixed-length fingerprint of some data. A hash function reads any amount of text and produces a string of characters, such as ba7816bf8f01cfea…. The same input always gives the same hash, even a one-character change gives a completely different hash, and you cannot work out the original text from the hash.
These properties make hashes useful for checking that a file or message was not changed, for storing passwords without keeping the passwords themselves, for digital signatures, and for creating unique IDs.
Hashing is not encryption
Encryption is two-way: you lock data with a key and unlock it later with a key. Hashing is one-way: there is no key and no way back. When a website checks your password, it hashes what you typed and compares it with the stored hash. It never needs the original password, and neither does an attacker who steals the hashes, who can only try to guess.
MD5, SHA-1, SHA-256, SHA-512 or bcrypt?
The right choice depends on what you are doing. This table summarises each algorithm available here.
| Algorithm | Result size | Status today | Best used for |
|---|---|---|---|
| MD5 | 128 bits (32 hex characters) | Broken: collisions are easy to create | Quick checksums where security does not matter, such as spotting accidental changes |
| SHA-1 | 160 bits (40 hex characters) | Deprecated: a real collision was shown in 2017 | Legacy systems only |
| SHA-256 | 256 bits (64 hex characters) | Secure | File integrity, signatures, certificates, most general uses |
| SHA-384 | 384 bits (96 hex characters) | Secure | Where a longer SHA-2 digest is required |
| SHA-512 | 512 bits (128 hex characters) | Secure | A larger security margin; often fast on 64-bit computers |
| bcrypt | 60-character string with salt and cost | Secure for passwords | Storing passwords |
How bcrypt works
bcrypt is a password hashing function. Unlike MD5 and SHA, which are designed to be fast, bcrypt is deliberately slow, which makes guessing passwords expensive for an attacker. It has three features worth knowing:
- Salt. bcrypt adds a random value to every hash, so the same password gives a different hash each time. The salt is stored inside the hash string, so verifying still works.
- Cost factor. The cost sets how much work is done: each step up doubles the time. A cost of 10 or more is recommended, and Laravel uses 12 by default. Choose the highest cost your server can handle without making logins feel slow.
- 72-byte limit. bcrypt only uses the first 72 bytes of the input. Longer passwords are cut off, so extra characters after that do not change the hash.
A bcrypt hash looks like $2y$10$…: the prefix names the version, the next number is the cost, and the rest holds the salt and the hash.
How to store passwords safely
- Never store passwords in plain text, and never use MD5, SHA-1 or a plain SHA-256 for passwords. They are fast, so billions of guesses per second are possible.
- Use a slow password hash: bcrypt or Argon2, through your framework’s built-in function.
- Let the library handle the salt. Do not invent your own.
- Re-hash a password at login when you increase the cost, so older hashes get upgraded.
- Add rate limiting, and offer two-factor authentication, so stolen hashes and guessed passwords matter less.
What is HMAC?
HMAC (hash-based message authentication code) mixes a secret key into the hash. Only someone who knows the key can produce the same result, so it proves a message came from the right sender and was not changed. It is widely used to sign API requests and webhooks. Enter a key in the HMAC key box to get HMAC-MD5, HMAC-SHA-256 and so on. bcrypt does not use a separate key.
Checking whether a text matches a hash
A hash cannot be reversed, so checking one means hashing the text again and comparing the two results. Open the Verify hash tab, enter the text and paste the hash. The tool works out the type from the hash itself (bcrypt, MD5, SHA-1, SHA-256, SHA-384 or SHA-512, written in hex or Base64) and tells you whether they match.
For bcrypt, the salt and cost are read from the hash, so it works with hashes created by other tools and languages that use the $2a$, $2b$ or $2y$ prefix. For the other types, hex hashes are compared without regard to letter case. If the hash was made with a secret key (HMAC), enter the key too. Use this to confirm a downloaded file’s checksum text, to test a password against a database hash, or to check a signature.
How this tool works, and your privacy
Unlike most tools on this site, the Hash Generator calculates results on our server, because bcrypt cannot be done natively in a browser. Your text is sent over an encrypted HTTPS connection, hashed in memory, returned to you and then discarded. It is not saved to a database, written to a log or shared with anyone, and responses are marked so that browsers do not cache them. Requests are rate limited to protect the service.
Even so, treat any online tool with care: do not paste a real production password or secret key. Use a test value instead, or generate the hash in your own code.
Creating hashes in your own code
Every major language can do this. In PHP, use hash() for digests and password_hash() with password_verify() for passwords:
$sha256 = hash('sha256', $text);
$hash = password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]);
$ok = password_verify($password, $hash);
In Laravel, use Hash::make($password) and Hash::check($password, $hash). In Node.js, use crypto.createHash('sha256'), and in Python, hashlib.sha256(text.encode()).hexdigest(). For bcrypt, use a maintained library for your language.