MD5
128-bit hash (32 hex characters)
SHA-1
160-bit hash (40 hex characters)
SHA-256
256-bit hash (64 hex characters) - Recommended
SHA-512
512-bit hash (128 hex characters)
What are Hash Functions?
A hash function is a cryptographic algorithm that takes an input (or 'message') and returns a fixed-size string of bytes. The output is typically a 'digest' that is unique to each unique input.
Key Properties:
- Deterministic: Same input always produces the same hash
- One-way: Cannot reverse a hash to get the original input
- Avalanche effect: Small change in input drastically changes the hash
- Collision resistant: Nearly impossible to find two inputs with the same hash
Hash Algorithm Comparison
| Algorithm | Bits | Security | Use Case |
|---|---|---|---|
| MD5 | 128 | Weak | Checksums only (not for security) |
| SHA-1 | 160 | Deprecated | Legacy systems (avoid for new projects) |
| SHA-256 | 256 | Strong | Recommended for most applications |
| SHA-512 | 512 | Very Strong | High security requirements |
Common Use Cases
Password Storage
Hash passwords before storing in databases
File Integrity
Verify files haven't been tampered with
Digital Signatures
Create unique identifiers for data
Data Deduplication
Identify duplicate content efficiently