hash-files icon indicating copy to clipboard operation
hash-files copied to clipboard

Concatenating files can generate same hash?

Open richardhuaaa opened this issue 8 years ago • 3 comments

As far as I understand, this works by concatenating all of the files together and then hashing the result. Does this mean that we can get the same hash when hashing this:

File 1: 00 01 02 File 2: 03 04 05

As well as this?

File 1: 00 01 02 03 File 2: 04 05

richardhuaaa avatar Jun 08 '16 21:06 richardhuaaa

That's true, thanks for uncovering this issue. I'll get this fixed soon.

mac- avatar Jun 16 '16 16:06 mac-

Oh, just another thing to note, I'm not sure how important this is to you, but this hashing algorithm also doesn't seem to factor in the names of the files. So if a file got renamed from a.js to aa.js, the hash would still come out the same.

richardhuaaa avatar Jun 21 '16 00:06 richardhuaaa

To solve both the issues at once, it would be enough to concatenate the full path of the file to the file data, and then hash.

I would create a PR, but I suppose this project is abandoned.

monteiz avatar Nov 26 '21 15:11 monteiz