Security · 3 min read ·
MD5, SHA-1 or SHA-256: which hash should you use?
Checksums, file integrity, passwords and signatures each need something different. A short guide to picking the right hash, and the one mistake to avoid.

A hash function turns any input into a short, fixed-length fingerprint. The same input always gives the same hash, and changing a single byte changes the result completely. What differs between algorithms is how hard they are to fool.
"hello" MD5 5d41402abc4b2a76b9719d911017c592
"hello" SHA-256 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
MD5 and SHA-1: broken for security
Two different inputs with the same MD5 hash can be produced in seconds, and practical SHA-1 collisions have been public since 2017. Don’t use them for signatures, certificates or anything an attacker could tamper with. They are still fine as quick checksums, such as finding duplicate files or building cache keys.
SHA-256: the safe default
For integrity checks, download verification, digital signatures and content addressing, SHA-256 from the SHA-2 family is the standard choice. SHA-3 and BLAKE2 are modern alternatives with a similar level of security.
CRC32: for accidents, not attacks
CRC32 and Adler-32 are fast checksums that detect accidental corruption in transfers and archives. Anyone can deliberately produce a matching value, so they give no protection against tampering.
Never store passwords with a fast hash
This is the most common mistake. Speed is exactly what you don’t want for passwords: a graphics card can try billions of SHA-256 guesses per second. Use a slow, salted algorithm made for passwords, such as Argon2, bcrypt or scrypt, through your framework’s password library.
Hashing, encryption and encoding are different things
Encoding Base64, hex, URL encoding reversible by anyone, no key
Encryption AES, RSA reversible only with the key
Hashing SHA-256, MD5 one-way, cannot be reversed
A hash can’t be “decrypted”. Websites that claim to reverse MD5 simply look the hash up in huge tables of known inputs, which works for common words and short passwords and fails for anything long and random.
Verify a download
Many projects publish a SHA-256 checksum next to their downloads. Hash the file you received and compare the two values; if a single character differs, the file is corrupted or not the one the publisher released. Every operating system has a built-in command:
Linux sha256sum file.iso
macOS shasum -a 256 file.iso
Windows certutil -hashfile file.iso SHA256
PowerShell Get-FileHash file.iso -Algorithm SHA256
Hash lengths
MD5 produces 128 bits (32 hex characters), SHA-1 160 bits (40), SHA-256 256 bits (64) and SHA-512 512 bits (128). If you need to prove who created a message, not just that it hasn’t changed, use an HMAC or a digital signature: a plain hash can be recomputed by anyone who changes the content.
Which one, in one line each
- Checking a download or a backup: SHA-256.
- Signatures, certificates and anything security-related: SHA-256 or stronger, never MD5 or SHA-1.
- Finding duplicate files or building cache keys: MD5 or SHA-1 are fine, and fast.
- Detecting transfer errors in a protocol or archive: CRC32.
- Storing passwords: none of the above; use Argon2, bcrypt or scrypt.
Why your hashes don’t match
If two tools give different hashes for the “same” text, the input is almost never the same: a trailing newline, Windows line endings or a different text encoding changes the whole result. The 4Dev Hash Generator hashes text as UTF-8 bytes, like md5sum, sha256sum and Python’s hashlib, and supports 17 algorithms, including MD5, SHA-1, SHA-2, SHA-3, BLAKE2 and CRC32.