Which hash should I use?
A hash function turns any input — a word, a file, a whole disk image — into a fixed-length digest. The same input always produces the same digest, a one-character change produces a completely different one, and the process cannot be reversed. That is all a hash guarantees. Choosing between MD5, SHA-1, SHA-256 and SHA-512 comes down to what you are using the digest for: spotting accidental damage, proving integrity against an attacker, authenticating a message, or storing a password.
The short answer
| Job | Pick |
|---|---|
| Detect accidental corruption | CRC-32, or SHA-256 if you want one tool for everything |
| Verify a download against a published checksum | Whatever the publisher used — normally SHA-256 |
| Prove a file has not been tampered with | SHA-256 or SHA-512 |
| Authenticate a message with a shared key | HMAC-SHA-256 |
| Store a user's password | Argon2id, then scrypt, bcrypt or PBKDF2 — never a plain hash |
| Match a legacy header or ETag | The algorithm the format mandates, often MD5 |
MD5 and SHA-1 are broken for security
Both are still fast and still fine for catching a corrupted download, but neither can protect you from an attacker. MD5 (128-bit) has had practical collisions — two different inputs with the same digest — since 2004, and chosen-prefix collisions since 2008, which is what let researchers forge a certificate authority signature. SHA-1 (160-bit) fell in 2017: Google and CWI produced two different PDFs with the same SHA-1 digest. Generating a collision does not let anyone recover a password, but it does let them substitute one file for another, which breaks signatures, certificates, and any "the digest matches, so it is the same file" check against an adversary.
So: use MD5 or SHA-1 only where the format dictates it (an object-storage ETag, a legacy protocol) and where nobody benefits from a collision. Never use them to sign anything, and never use them for passwords.
SHA-2 is the current default
SHA-256, SHA-384 and SHA-512 are the SHA-2 family. There are no practical attacks on SHA-2, and all three are available through the browser's Web Crypto API, so they cost you nothing in portability. SHA-256 is the right default; SHA-512 is a fine choice on 64-bit hardware and whenever you want a wider margin; SHA-384 shows up in TLS and in Subresource Integrity attributes. SHA-3 (Keccak) is a later standard built on a different construction and stands ready as a backup — pick it if your platform offers it and you want independence from SHA-2, but there is no need to migrate away from SHA-256 today.
Why MD5 is unsafe for passwords
A plain hash of a password is the same every time, so an attacker who gets your database can simply look the digest up in a precomputed rainbow table of common passwords and read the original in microseconds. Even a random password falls to brute force because SHA-256 and its relatives were designed to be fast — fast enough to try billions of candidates per second on a GPU. "Fast" is exactly what you do not want when the input is a password.
Password storage therefore uses deliberately slow, keyed, memory-hard constructions: Argon2id is the modern recommendation, with scrypt, bcrypt and PBKDF2 as widely deployed alternatives. They mix in a random salt so identical passwords produce different digests, and their cost parameters are tuned to make guessing expensive. The PBKDF2 key derivation tool applies that idea to derive keys and verify passwords on-device.
When you need HMAC, not a hash
A plain SHA-256 digest is public: anyone can recompute it from the input, so it proves integrity but says nothing about who produced the message. HMAC (hash-based message authentication code) fixes that by mixing a secret key into the hashing, giving you an authenticated digest that an attacker cannot forge without the key. Reach for HMAC-SHA-256 whenever you share a secret and need to prove a message came from the other party: API authentication, webhook signatures, signed session tokens. The HMAC generator tool computes these directly.
One clean way to think of it: a hash answers "did the bytes change?" and HMAC answers "did the bytes change, and do I trust who changed them?"
Using the tools
The Text Hash Generator computes MD5, SHA-1, SHA-256, SHA-384 and SHA-512
in hex, Base64 or base64url; File Hash does the same for an uploaded
file; and Hash Identifier guesses which algorithm an unknown
digest belongs to. For integrity on the web, the
SRI hash generator builds the integrity attributes you drop
on a script or link tag.
More guides
- Base64 explained — encoding, not hashing, and when to use it.
- Cron syntax cheat sheet — scheduling with cron.
- Colour contrast and WCAG — accessible colour choices.