What Is a Hash Function?
A hash function takes any input (text, file, password) and produces a fixed-size string of characters called a hash or digest. The key properties:
- Deterministic — the same input always produces the same hash
- One-way — you cannot reverse a hash to get the original input
- Unique — different inputs produce different hashes (ideally)
- Fixed-length — the output is always the same length regardless of input size
Common Hash Algorithms
MD5 (Message Digest 5)
- Output: 128-bit (32 hex characters)
- Example:
5d41402abc4b2a76b9719d911017c592(hash of "hello") - Speed: Very fast
- Security: Broken — do NOT use for security purposes
- Use for: File checksums, non-security cache keys
SHA-1 (Secure Hash Algorithm 1)
- Output: 160-bit (40 hex characters)
- Example:
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d(hash of "hello") - Speed: Fast
- Security: Deprecated — collision attacks exist
- Use for: Legacy systems, git commit hashes
SHA-256 (SHA-2 family)
- Output: 256-bit (64 hex characters)
- Example:
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 - Speed: Moderate
- Security: Strong — current industry standard
- Use for: Password hashing, digital signatures, blockchain, data integrity
SHA-512 (SHA-2 family)
- Output: 512-bit (128 hex characters)
- Speed: Slightly slower than SHA-256
- Security: Very strong
- Use for: High-security applications, when maximum security is needed
When to Use Each Hash
| Use Case | Recommended Hash |
| Password storage | SHA-256 + salt (or bcrypt/argon2) |
| File integrity checks | SHA-256 |
| Digital signatures | SHA-256 or SHA-512 |
| Cache keys | MD5 (speed matters, security doesn't) |
| Git commits | SHA-1 (by convention) |
| Blockchain | SHA-256 |
| API request signing | SHA-256 |
How Hashing Works in Practice
Password Storage
Never store passwords in plain text. Instead:
File Integrity Verification
When downloading software:
API Security
Many APIs use hash-based message authentication (HMAC):
Hash Collisions
A collision occurs when two different inputs produce the same hash. This is a critical security issue:
- MD5 — collisions can be generated in seconds. Never use for security.
- SHA-1 — collisions demonstrated in 2017 (SHAttered attack). Deprecated.
- SHA-256 — no known collisions. Considered secure.
- SHA-512 — no known collisions. Highest security.
Generate Hashes Online
Use our free Hash Generator to create MD5, SHA-1, SHA-256, and SHA-512 hashes instantly. All processing happens in your browser — your data is never sent to any server.
Try it with any text, compare different algorithms side by side, and verify file integrity — all free, all private.