What Is a Hash?
A hash maps arbitrary-length input to a fixed-length output (digest) via a one-way function. A good cryptographic hash is: deterministic (same input → same output), avalanche (one bit change flips output completely), collision-resistant (hard to find two inputs with the same digest), and one-way (hard to reverse).
But "one-way" is not "unbreakable" — for short or common strings, attackers reverse them with rainbow tables or brute force. So the hash function must match the job.
Four Jobs, Four Choices
| Job | Recommended | Why |
|---|---|---|
| File integrity check | MD5 / SHA-256 | Fast and reproducible; goal is detecting corruption, not thwarting attackers |
| Data fingerprint / dedup | SHA-256 | Negligible collision probability, stable output |
| Tamper-evident signing | SHA-256 / SHA-512 | Verify content unchanged (pair with a key via HMAC) |
| Password storage | BCrypt / Argon2 | Slow hash + salt, designed to resist brute force |
MD5 / SHA-1: Unsafe but Still Useful
MD5 (128-bit) and SHA-1 (160-bit) have demonstrable collision attacks and must never be used for security tokens, signatures, or certificates. But for "file dedup", "cache keys", or "non-adversarial checksums" — where no attacker is trying to fool you — they remain fast and perfectly fine.
Rule of thumb: if an attacker could craft inputs to deceive you, don't use MD5/SHA-1. Otherwise (e.g. local file comparison) it's acceptable.
SHA-2 Family: The Default Safe Choice
SHA-256 / SHA-384 / SHA-512 belong to SHA-2. No practical collision attack is known; they are the default for most security scenarios:
- SHA-256: 256-bit output, the most universal — blockchains, certificates, Git commits, file signing.
- SHA-512: 512-bit output, faster on 64-bit CPUs, slightly better against length-extension attacks.
Why Passwords Must Not Use SHA
SHA's design goal is speed — its strength, and a fatal flaw for password storage. An attacker with one GPU computes billions of SHA hashes per second, breaking weak passwords instantly.
Password storage needs a slow hash + salt:
- BCrypt: adaptive cost factor, slows as hardware improves; salts automatically.
- Argon2: 2015 Password Hashing Competition winner, memory-hard against GPU/ASIC.
- SCrypt: memory-hard, also resists hardware acceleration.
This site's hash-text is a general-purpose one-way hash tool for checksums, fingerprints, and signature verification. For password storage, use a dedicated BCrypt-class scheme — do not "just hash the password and store it" here.
Hash ≠ Encryption
- Encryption (AES, etc.): reversible — a key restores the plaintext → protects confidentiality.
- Hash (SHA/MD5/BCrypt): one-way — not reversible → verifies integrity / generates fingerprints.
Need the data back? Use encryption, not a hash.
Best Practices
- Use SHA-256 for checksums/fingerprints; don't fall back to MD5 for security uses.
- Use HMAC-SHA256 for tamper evidence; let the key participate in the hash.
- Use BCrypt/Argon2 for passwords; never bare SHA.
- Don't treat a hash as encryption: if you need to recover data, use AES.
- No random salt for reproducible scenarios (file checksums); always salt passwords.