MD5 vs SHA-1 vs SHA-256: Hash Algorithm Comparison
Hash algorithms convert data of any size into a fixed-length "digest." They are designed to be one-way (cannot reverse the hash to get the original) and deterministic (same input always produces the same output).
MD5 produces a 128-bit (32 hex character) digest. It was designed in 1991 and is now cryptographically broken — attackers can create two different files with the same MD5 hash (collision attack). MD5 should never be used for security purposes. It is still useful for non-security checksums to detect accidental file corruption during download.
SHA-1 produces a 160-bit (40 hex character) digest. It was broken by Google and CWI Amsterdam in 2017 with the SHAttered attack, demonstrating a practical collision. Git, which uses SHA-1, has been migrating away. SHA-1 should not be used for new security applications.
SHA-256 produces a 256-bit (64 hex character) digest. It is part of the SHA-2 family and is currently considered secure. Used in TLS/SSL certificates, Bitcoin mining, password hashing (with salt), and file integrity verification. No practical collision attack is known.
SHA-512 produces a 512-bit (128 hex character) digest. Also part of SHA-2. Offers stronger theoretical collision resistance than SHA-256 at the cost of computational overhead. Used where maximum security margin is desired.
For password storage: Never use raw SHA-256. Use bcrypt, scrypt, or Argon2 — they are designed to be slow and resistant to brute-force attacks. Raw hash functions are too fast.
Use Tooler's Hash Generator to generate MD5, SHA-1, SHA-256, and SHA-512 hashes from any text input.