Hash Generator
Generate MD5, SHA-1, SHA-256, SHA-384, and SHA-512 hashes from text input.
// Using Web Crypto API (SHA-256)async function sha256(text) {const encoder = new TextEncoder();const data = encoder.encode(text);const hash = await crypto.subtle.digest('SHA-256', data);return Array.from(new Uint8Array(hash)).map(b => b.toString(16).padStart(2, '0')).join('');}// Node.jsconst crypto = require('crypto');const hash = crypto.createHash('sha256').update('text').digest('hex');
You May Also Like
What is Hashing?
Imagine you have a magic machine that can turn any book into a unique fingerprint - no matter how long the book is, the fingerprint is always the same length. That's essentially what a hash function does!
A hash function takes any input (text, file, password) and converts it into a fixed-length string of characters called a hash or digest. The same input always produces the same hash, but even a tiny change creates a completely different result.
Why does this matter to you?
- Password security: Websites store hashes of your passwords, not the actual passwords
- File verification: Download a file and check its hash to ensure it wasn't corrupted or tampered with
- Data integrity: Detect if data has been modified
Common Hash Algorithms
| Algorithm | Output Length | Security | Use Case |
|---|---|---|---|
| MD5 | 128 bits (32 hex) | ❌ Broken | Legacy systems, checksums |
| SHA-1 | 160 bits (40 hex) | ❌ Weak | Git commits (legacy) |
| SHA-256 | 256 bits (64 hex) | ✅ Secure | Bitcoin, SSL certificates |
| SHA-512 | 512 bits (128 hex) | ✅ Very Secure | High-security applications |
| SHA-3 | Variable | ✅ Most Secure | Next-gen security |
Rule of thumb: For new projects, always use SHA-256 or SHA-3. MD5 and SHA-1 are considered cryptographically broken.
Real-World Examples
🔐 How Websites Store Your Password
When you create an account with password "MySecret123":
- Website hashes it:
MySecret123→a1b2c3d4e5f6... - Only the hash is stored in the database
- When you log in, your input is hashed and compared
Even if hackers steal the database, they only get hashes - not your actual passwords!
📦 Verifying Downloaded Files
Ever seen "SHA-256 checksum" on a download page? Here's how to use it:
- Download the file
- Generate its hash using this tool
- Compare with the official checksum
- If they match, the file is authentic and uncorrupted
⛓️ Bitcoin Mining
Bitcoin miners race to find a hash that starts with many zeros. The first to find it wins the block reward. This requires trillions of hash calculations per second!
Key Properties of Good Hash Functions
1. Deterministic Same input → Same output, every time.
"hello" → always "2cf24dba5fb0a30e..."
2. Fast to Compute Hashing a file should take milliseconds, not minutes.
3. One-Way (Pre-image Resistance) You cannot reverse a hash to get the original input.
"2cf24dba5fb0a30e..." → ??? (impossible to find "hello")
4. Avalanche Effect A tiny change creates a completely different hash:
"hello" → "2cf24dba5fb0a30e26e83b2ac5b9e29e..."
"hellp" → "7f9351a8b1b6a7d3c4e5f6a7b8c9d0e1..." (completely different!)
5. Collision Resistant It should be practically impossible to find two different inputs that produce the same hash.
Security Best Practices
Never use MD5 or SHA-1 for security purposes! They are vulnerable to collision attacks.
For Password Storage:
- Use specialized password hashing algorithms: bcrypt, Argon2, or scrypt
- These are intentionally slow to prevent brute-force attacks
- Always add a unique salt (random data) to each password
For File Integrity:
- SHA-256 is the current standard
- Always verify hashes from the official source
For Digital Signatures:
- Use SHA-256 or SHA-3
- Consider the signature algorithm (RSA, ECDSA) as well
Fun Facts About Hashing
🎯 The Birthday Paradox In a room of just 23 people, there's a 50% chance two share a birthday. Similarly, finding hash collisions is easier than you'd expect - which is why we need long hashes!
💰 SHA-256 in Your Pocket Every Bitcoin transaction is secured by SHA-256. The entire cryptocurrency economy depends on this algorithm remaining secure.
🔢 How Many Possible SHA-256 Hashes? 2^256 = 115,792,089,237,316,195,423,570,985,008,687,907,853,269,984,665,640,564,039,457,584,007,913,129,639,936
That's more than the number of atoms in the observable universe!