Hash functions turn data of any size into a fixed-length “fingerprint.” They’re everywhere — file downloads, password storage, digital signatures, deduplication. But not all hash functions are safe to use today. Here’s how MD5, SHA-256 and SHA-512 compare, and how to use them correctly.
The same input, three lengths.
hellothrough our hash generator:MD5 5d41402abc4b2a76b9719d911017c592 (32 hex chars = 128 bits) SHA-1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d (40 = 160 bits) SHA-256 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 (64 = 256 bits)Every hash of a given algorithm is the same length no matter how long the input is — that is what makes them useful as fingerprints. But length is not the security story: MD5 and SHA-1 both have practical collision attacks, SHA-256 does not. Copy any of these into another tool and you should get a byte-identical result.
What a hash is (and isn’t)
A cryptographic hash is a one-way function: given the output, you cannot recover the input. The same input always yields the same output, and changing a single character changes the result completely. That’s why hashes are used to check integrity and store passwords — you compare fingerprints, not the original data.
A hash is not encryption (there’s no key and no decryption) and not encoding (like Base64, which is reversible by anyone).
Why MD5 is considered broken
MD5 produces a 128-bit hash and was once ubiquitous. The problem is collisions — different inputs that produce the same hash. Researchers have been able to generate MD5 collisions cheaply for years, which means MD5 can no longer guarantee integrity: an attacker could craft a malicious file with the same MD5 as a legitimate one.
For this reason, MD5 (and the older SHA-1) should not be used for security purposes. Our hash generator still computes MD5 and SHA-1 alongside the SHA-2 family — precisely so you can compare them side by side and see why the older algorithms are only fit for non-security checks like file checksums.
SHA-256 vs. SHA-512
Both belong to the SHA-2 family and are considered secure today. The differences:
- SHA-256 produces a 256-bit (64 hex character) hash. It’s the most widely used and a great default.
- SHA-512 produces a 512-bit (128 hex character) hash. It offers a larger output and can actually be faster on 64-bit hardware.
For most purposes — file checksums, integrity checks, general fingerprinting — SHA-256 is the sensible default. Choose SHA-512 when a longer digest is required by a standard or protocol.
The number in each name is the digest length in bits, and a single input makes it concrete. All four of these are the word hello, hashed in your browser by our own hash generator:
MD5 5d41402abc4b2a76b9719d911017c592 (32 hex chars / 128 bits)
SHA-1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d (40 hex chars / 160 bits)
SHA-256 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 (64 hex chars / 256 bits)
SHA-512 9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043 (128 hex chars / 512 bits)
Now change the input by one capital letter. Hello under SHA-256 is 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969, which has nothing in common with the hello value above — yet it is exactly as long. Feed in a two-hour video file instead and the four lengths are still exactly these. Fixed output length regardless of input size is what makes a hash a hash; the choice between these four is only about how hard that output is to forge.
The right way to store passwords
Here’s a critical point: you should not store passwords with a plain hash, not even SHA-256. Fast hashes are easy to brute-force with modern hardware. Instead, use a purpose-built password hashing algorithm that is deliberately slow and salted, such as bcrypt, scrypt or Argon2. These add a unique random salt per password and a tunable work factor to resist cracking.
So the rule of thumb:
- File integrity / fingerprints → SHA-256 (or SHA-512).
- Password storage → bcrypt / scrypt / Argon2 with a salt — never a bare SHA hash.
Upgrading the algorithm does not fix password storage. password under SHA-256 is 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8 — a value just as public as its MD5, because a fast hash is fast for the attacker too. Password storage needs a deliberately slow function (bcrypt, scrypt, Argon2) and a per-user salt. Digest length is irrelevant to that problem.
Verifying a download
A common, legitimate use of hashing is checking that a downloaded file wasn’t corrupted or tampered with. The publisher lists the file’s SHA-256; you compute the hash of your copy and compare. If they match, the file is intact.
You can compute SHA-256, SHA-384 and SHA-512 in your browser with our free hash generator — it uses the native Web Crypto API, so your input is never uploaded.