Hash functions are one of the most fundamental building blocks in computer science and cryptography. They take arbitrary input and produce a fixed-size output (the "hash" or "digest") that acts as a unique fingerprint of the data. This guide compares the most commonly used hash functions, explains when each is appropriate, and clarifies why some are no longer safe for security purposes.
What Is a Hash Function?
A cryptographic hash function has five essential properties:
- Deterministic: The same input always produces the same output.
- Fast to compute: Generating a hash is computationally efficient.
- Pre-image resistant: Given a hash, it is infeasible to find the original input.
- Small changes cascade: Changing even one bit of input completely changes the output (avalanche effect).
- Collision resistant: It is infeasible to find two different inputs that produce the same hash.
Hash Function Comparison
| Algorithm | Output Size | Speed | Collision Resistance | Status |
|---|---|---|---|---|
| MD5 | 128 bits (32 hex) | Very fast | Broken | Deprecated for security |
| SHA-1 | 160 bits (40 hex) | Fast | Broken | Deprecated for security |
| SHA-256 | 256 bits (64 hex) | Moderate | Strong | Current standard |
| SHA-384 | 384 bits (96 hex) | Same as SHA-512 | Strong | Active |
| SHA-512 | 512 bits (128 hex) | Moderate | Strong | Active |
| SHA-3 (256) | 256 bits (64 hex) | Moderate | Strong | Active (Keccak-based) |
| BLAKE3 | 256 bits (variable) | Very fast | Strong | Modern alternative |
Why MD5 and SHA-1 Are Broken
MD5 was designed by Ron Rivest in 1991 and was the standard hash function for over a decade. In 2004, researchers demonstrated practical collision attacks, and by 2008, collisions could be generated in seconds on ordinary hardware. Today, MD5 should never be used for any security purpose.
SHA-1 (Secure Hash Algorithm 1) was designed by the NSA and published in 1995. In 2017, Google and CWI Amsterdam demonstrated the first practical SHA-1 collision (the "SHAttered" attack). Major browsers, Git, and certificate authorities have since moved away from SHA-1.
Still safe for non-security use: MD5 and SHA-1 remain perfectly fine for checksums, cache keys, data deduplication, and hash-based data structures where adversarial collision resistance is not required.
SHA-2 Family: The Current Standard
SHA-256 and SHA-512 belong to the SHA-2 family, designed by the NSA and published in 2001. SHA-256 is the most widely used hash function in the world today:
- Bitcoin and blockchain: SHA-256 is the proof-of-work algorithm for Bitcoin mining.
- TLS/SSL certificates: All modern HTTPS certificates use SHA-256 signatures.
- File integrity: Software downloads commonly provide SHA-256 checksums for verification.
- Digital signatures: ECDSA and RSA signatures typically hash with SHA-256.
SHA-512 uses 64-bit operations and is actually faster than SHA-256 on 64-bit processors. SHA-384 is a truncated variant of SHA-512.
SHA-3: The Insurance Policy
SHA-3 was standardized in 2015 after a public competition (won by the Keccak team). It is not a replacement for SHA-2 — SHA-2 remains unbroken. Rather, SHA-3 provides a fundamentally different design (sponge construction vs Merkle-Damgard) as insurance against a future breakthrough that might affect SHA-2.
BLAKE3: The Speed Champion
BLAKE3 (2020) is the fastest general-purpose hash function, significantly outperforming SHA-256 and SHA-3. It is parallelizable, supports incremental hashing, and produces output of any length. BLAKE3 is increasingly used in file integrity checking, content-addressed storage, and performance-sensitive applications.
Hash Functions for Password Storage
Never use raw SHA-256 or MD5 for passwords. General-purpose hash functions are too fast — an attacker can test billions of password guesses per second. Instead, use purpose-built password hashing algorithms:
| Algorithm | Recommendation | Key Feature |
|---|---|---|
| Argon2id | Best choice (2015) | Memory-hard, resistant to GPU attacks |
| bcrypt | Good choice (1999) | Adaptive cost factor, widely supported |
| scrypt | Good choice (2009) | Memory-hard, configurable parameters |
| PBKDF2 | Acceptable (legacy) | Simple, NIST-approved, but not memory-hard |
These algorithms are deliberately slow and include a random salt to prevent rainbow table attacks. Argon2id is the current recommendation from OWASP and the Password Hashing Competition.
Choosing the Right Hash Function
- File checksums and integrity: SHA-256 (standard) or BLAKE3 (faster)
- Digital signatures and certificates: SHA-256
- Password storage: Argon2id, bcrypt, or scrypt (never raw SHA/MD5)
- Cache keys and deduplication: MD5 or SHA-1 (speed matters, adversarial resistance does not)
- Blockchain and proof-of-work: SHA-256 (Bitcoin) or Ethash/Keccak-256 (Ethereum)
- Maximum future-proofing: SHA-3 or BLAKE3
Generate and verify hashes instantly with the WizlyTools Hash Generator — supporting SHA-256, SHA-384, and SHA-512 directly in your browser.