How to Generate Cryptographic Hashes
Hash Generation
When to Hash Data
Hashes produce a fixed-size fingerprint of input data. Use them for checksums, deduplication keys, cache keys, and verifying file integrity — not for storing passwords (use bcrypt or Argon2 instead).
Algorithm Guide
- SHA-256 — default choice for most checksums and fingerprints
- SHA-512 — longer output, same family as SHA-256
- SHA-1 — legacy; avoid for security-sensitive use
- MD5 — legacy checksums only; not collision-resistant
Common Mistakes
- Trailing newline differences changing the hash output
- Using MD5 or SHA-1 for security-critical integrity checks
- Confusing hashing with encryption — hashes are one-way fingerprints
Developer Tips
- Node.js:
crypto.createHash('sha256').update(data).digest('hex') - Normalize line endings before hashing text files cross-platform
- Use HMAC when you need a secret-keyed digest, not plain hash
Frequently asked questions
Is hashing done locally?
Yes. All hash computation runs in your browser using the Web Crypto API (or a small MD5 library). Nothing is sent to a server.
Why is my hash different from another tool?
Hashes are sensitive to exact input bytes. Differences in trailing newlines, encoding (UTF-8 vs Latin-1), or uppercase hex output can cause mismatches.