Hash Mismatch Error — How to Debug and Fix
💡A hash mismatch means the computed hash does not match the expected value. The most common causes are encoding differences, Unicode normalization, algorithm mismatch, or comparing hex output to Base64 output. Normalize the input, confirm the algorithm and encoding, and compare hashes in the same format.
Quick Diagnosis
If you see “hash mismatch on file download” → it means the file was corrupted or modified in transit → do this: re-download the file and recompute the hash before comparing
If you see “hash mismatch on password verify” → it means the stored hash was generated from a different input or algorithm → do this: confirm you are hashing the same string (check for trailing spaces or encoding differences)
If you see “hash mismatch in API signature check” → it means the secret key, message format, or algorithm differs between sender and receiver → do this: verify secret key encoding (hex vs. UTF-8), message encoding, and HMAC algorithm match
If you see “same input produces different hashes” → it means invisible characters, encoding differences, or algorithm mismatch → do this: compare byte-level input using a hex encoder, and confirm algorithm (MD5, SHA-256, etc.)
Common Causes and Fixes
Encoding difference causes mismatch
❌ Wrong
// Hashing UTF-16 string vs UTF-8
const hash1 = sha256("café"); // UTF-8 bytes
const hash2 = sha256("cafe\u0301"); // decomposed form
// hash1 !== hash2✅ Fixed
// Normalize before hashing
const normalized = input.normalize("NFC");
const hash = sha256(normalized);Unicode normalization form affects the bytes fed to the hash function. Always normalize before hashing.
Hex vs. Base64 output comparison
❌ Wrong
// Comparing hex output to Base64 output
const hex = "2cf24dba...";
const b64 = "LPJNug=="; // same hash, different encoding
hex === b64 // false✅ Fixed
// Convert to same format before comparing
const hexFromB64 = Buffer.from(b64, "base64").toString("hex");
hexFromB64 === hex // trueBoth are the same hash value — just encoded differently. Convert to one format before comparing.
Debugging Checklist
- ✓Confirm both sides use the same algorithm (MD5, SHA-256, SHA-512)
- ✓Compare outputs in the same encoding — both hex or both Base64
- ✓Check for trailing newlines or spaces in the input string
- ✓Normalize Unicode input to NFC form before hashing
- ✓For API signatures, verify the secret key encoding matches (hex, UTF-8, Base64)
- ✓For file verification, re-download the file before recomputing
Generate and Compare Hashes
Compute MD5, SHA-1, SHA-256, and SHA-512 hashes in the browser to verify your input and compare against the expected value.
Related Guides
Frequently Asked Questions
Why does the same input produce a different hash?
The most common causes are character encoding differences (UTF-8 vs UTF-16), Unicode normalization, trailing newlines, or using a different algorithm or key.
How do I compare hashes correctly?
Always compare hashes in the same encoding (both hex or both Base64). Never compare a hex string to a Base64 string directly.
Can a hash mismatch mean the file was tampered with?
Yes. If you recompute the hash and it differs from the published checksum, the file may have been corrupted, truncated, or modified.
All tools run in your browser. Your data never leaves your device.