Skip to main content

Same File Size Does Not Mean Duplicate

Updated 2 min readMarkdown

Two files, same name, same size. Must be duplicates, right? I tested that assumption with a real Node.js run, and it failed. Full run in this Short: https://youtu.be/nrhOO58008Y

The test

I made two notes files with the same name and the same size: 1,920 bytes each. If size were a reliable duplicate check, these two would be the same file.

Then I hashed both with SHA-256 in Node.js. The hashes were different. Different hashes mean different content, so the files are not duplicates, even though the name and size match exactly.

Why size is not enough

Size is a count, not a fingerprint. Two files reach the same byte count in endless ways: swap two paragraphs, change a word for a longer one and trim elsewhere, or just have unrelated content that happens to add up the same. A hash reads every byte, so any change, anywhere, changes the result.

That is why real duplicate finders use size only as a first pass. Group files by size to skip the obvious non-duplicates cheaply, then hash only the groups that collide. Checking size first is fast; trusting size alone is wrong.

Watch the run

The real terminal output is in the Short: https://youtu.be/nrhOO58008Y (narration is AI-generated; the test output is from a real run). The full duplicate-finder build is here: https://youtu.be/SFwkTAPenzw

Subscribe to Ship Stack AI on YouTube and tell me in the comments what to build and break next.

About the author

  • Real AI-built Node.js projects, tools and workflows. Every experiment is built and load-tested on camera, with the real numbers. Videos: https://www.youtube.com/@ShipStackAI

Good breakdown of the two-step check: size first, then hash. Why SHA-256 and not something quicker for the duplicate check?