Which hash algorithm should I use?
| Algorithm | Output | Security | Typical use |
|---|---|---|---|
| MD5 | 128 bits (32 hex chars) | Broken | Non-security checksums, cache keys, deduplication |
| SHA-1 | 160 bits (40 hex chars) | Broken | Legacy systems, Git object IDs (moving to SHA-256) |
| SHA-256 | 256 bits (64 hex chars) | Secure | Checksums, signatures, HMAC, Bitcoin, TLS certificates |
| SHA-384 | 384 bits (96 hex chars) | Secure | TLS cipher suites, Subresource Integrity |
| SHA-512 | 512 bits (128 hex chars) | Secure | Signatures, Linux password hashing ($6$) |
| CRC32 | 32 bits (8 hex chars) | Not cryptographic | Detecting accidental corruption: ZIP, PNG, Ethernet |
For anything new, choose SHA-256. The hex length is also a quick way to identify an unknown hash: 32 characters is almost always MD5, 40 is SHA-1 and 64 is SHA-256.
Generate hashes on the command line
# Linux
sha256sum file.iso
md5sum file.iso
echo -n 'hello world' | sha256sum
# macOS
shasum -a 256 file.iso
md5 file.iso
# Verify against a published checksum file
sha256sum -c SHA256SUMS
# HMAC-SHA256
echo -n 'message' | openssl dgst -sha256 -hmac 'secret'
Hashing in code
import { createHash, createHmac } from 'node:crypto';
createHash('sha256').update('hello world').digest('hex');
createHmac('sha256', 'secret').update('message').digest('hex');
const bytes = new TextEncoder().encode('hello world');
const digest = await crypto.subtle.digest('SHA-256', bytes);
const hex = [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, '0')).join('');
import hashlib, hmac
hashlib.sha256(b"hello world").hexdigest()
hmac.new(b"secret", b"message", hashlib.sha256).hexdigest()
# Compare signatures in constant time
hmac.compare_digest(expected, received)
Web Crypto has no MD5, which is why many browser-based tools can’t offer it; this one includes its own implementation. To encode the raw hash bytes differently, see Base64.
Frequently asked questions
What is a hash function?
A hash function turns input of any size into a fixed-size fingerprint. The same input always gives the same hash, a tiny change gives a completely different one, and you can’t work backwards from the hash to the input. That makes hashes useful for checksums, signatures and deduplication.
Is MD5 still safe to use?
Not for security. Researchers can create two different files with the same MD5 hash in seconds, and SHA-1 collisions have been demonstrated too. They are fine for detecting accidental corruption or as cache keys, but use SHA-256 for anything an attacker might tamper with.
Can I hash passwords with SHA-256?
You shouldn’t. SHA-256 is designed to be fast, so attackers can test billions of guesses per second against a leaked database. Use a slow password hashing function with a salt: Argon2id, scrypt or bcrypt.
How do I verify a downloaded file’s checksum?
Click “Hash a file”, choose the download and paste the checksum from the publisher’s website into the compare box. If the matching algorithm is highlighted, the file is intact. The file is hashed locally and never uploaded, even if it is large.
What is HMAC?
HMAC is a hash combined with a secret key. Only someone with the key can produce the right value, so it proves a message is authentic and unmodified. GitHub, Stripe, Shopify and Slack sign webhooks with HMAC-SHA256 of the raw request body.
Why does my hash differ from the one my code produces?
Usually because the input bytes differ: a trailing newline (echo adds one; use echo -n), Windows CRLF line endings, a different text encoding, or hashing a JSON object after re-serializing it with different whitespace. This tool hashes exactly the UTF-8 bytes of what you type.