Skip to content
OneKitly

Two Nearly Identical Files Get Completely Unrelated Hashes

Published 11/24/2026 · 3 min read · Developer tools

Daniel Okonkwo

Daniel Okonkwo — Front-end developer and tech writer at OneKitly

Web performance · File formats

Checked against 2 sources

View profile →
In short

Hash "hello" with SHA-1 and you get aaf4c61d…; hash "hellp", one letter apart, and you get d4baaad7…. Comparing the two bit by bit, 85 of the 160 bits differ. Repeat the experiment over five hundred pairs that differ by a single trailing space and the average is 80.5 bits — 50.3%, which is what you would get from two random values. This is the avalanche property, and it is deliberate: a hash function is built so that no information about the input survives into the neighbourhood structure of the output.

Advertisement

Add a single space and 80 of the 160 output bits flip. That is the design working, and it is why you cannot compare hashes to judge similarity.

What to use when you do want similarity

Deduplicating photos, spotting a near-copy of a document or grouping variants of a file all need the opposite property, and they use different tools: perceptual hashes for images, which survive resizing and recompression, and fuzzy or context-triggered hashes for byte streams, which produce comparable values for similar inputs. Neither is a cryptographic hash, and neither should be used to verify integrity — they are built to leak exactly the information SHA-1 is built to destroy.

Half the bits is the target, not an accident

A function whose outputs changed by only ten per cent for a one-bit input change would be a broken one: an attacker could hill-climb towards a target value, and anyone could tell how close two inputs were. Fifty per cent is the value you would get by chance, so it is the value that reveals nothing. When cryptographers publish an avalanche measurement, they are checking that the function has no exploitable structure left, not that it is impressively scrambled.

One letter changed, measured in bits
InputSHA-1, first 8 digitsBits differing from the row above
helloaaf4c61d—
hellpd4baaad785 of 160
empty stringda39a3eeabout half, as always
500-pair average—80.5 (50.3%)
SHA1 Hash GeneratorGenerate a SHA-1 hash of any text instantly in your browser, with hex or Base64 output. 160-bit — deprecated for security uses.Try the tool →
Advertisement

Frequently asked questions

Is SHA-1 still safe to use?
Not against an adversary. A practical collision was demonstrated in 2017 at a cost of about two to the sixty-third operations, roughly a hundred thousand times cheaper than the two-to-the-eightieth a birthday attack would need, and the cost has fallen since. It is still perfectly adequate for detecting accidental corruption — a truncated download, a flipped bit on disk — because random damage does not aim at anything. Use SHA-256 wherever someone might be trying.
Why do hashes have a fixed length?
Because the function compresses an input of any size into a fixed number of bits — 160 for SHA-1, 256 for SHA-256 — which is what makes them comparable and storable. It also means collisions must exist: there are more possible inputs than outputs, by an unimaginable margin. Security does not come from collisions being impossible, only from them being impossible to find on purpose, which is precisely what an attack like the 2017 one removes.

Articles you may find interesting

All guides →
ComparisonMD5, SHA-1, SHA-256: Which Hash, and For WhatMD5 is broken and MD5 is fine, depending on which of three security properties you needed. Here is what collision resistance, second-preimage resistance and preimage resistance actually mean, which algorithm still has which, and why none of them belongs near a password.ComparisonChecksums Are Not Hashes: CRC-32, Adler-32 and What They Are ForA checksum catches accidents. A cryptographic hash resists an attacker. A hash-table hash spreads keys. Three different jobs, three different families — and here is a CRC-32 collision constructed by hand in 0.11 seconds to show exactly why you cannot substitute one for another.ExplainerPassword Entropy: What a Strength Meter Cannot KnowEntropy measures the process that produced a password, not the characters in it. H = L x log2(R) is only true when every character was chosen at random — which is exactly why a meter scoring a human-invented password on its character classes is measuring the wrong thing.ExplainerWhat Is Inside a JWT — and What It Does Not ProtectA JWT is signed, not encrypted. Anyone holding the token can decode the payload and read every claim in it. Here is a real token, decoded without any key, plus the three attacks the signature is supposed to stop and the one problem it cannot solve.GuideEncrypt a File, Then Send the Key Down a Different RoadThe encryption is the easy half. Here is exactly what the browser tool does to your file — cipher, key derivation, salt, nonce — and why an encrypted attachment with the passphrase in the same thread protects nothing at all.How-toSending a Document for Signature: the Workflow, Not the LawWhether a drawn signature is valid is settled elsewhere. What decides whether your document actually gets signed is the order you ask people in, what the audit trail records, and six failure modes that have nothing to do with the law.

Related tools

Sources

Spotted a mistake in this article?