Skip to content
Advertisement

Zip files contain same files but have different hashes?

I have created hundreds of folders and text files using php, I then add them to a zip archive.

This all works fine but if I create another zip archive using the same folders and files, the new archive will have a different hash to the first one. This is the same if I use winrar instead of php to create an archive.

It only seems to show different hashes when I zip the files I have created through php, yet they open fine.

Very strange anyone shed any light on this?

Thanks

Advertisement

Answer

There is certainly some difference in the files. If the lengths are not exactly the same, the hash will be different. You can use a comparing hex editor, like Hex Workshop for example, to see what exactly the differences are.

Possibilities that come to my mind:

  1. As @orn mentioned, there may be a timestamp in the zip format you are using (not sure).
  2. The order that the files are added to the archive may be different (depending on how you’re selecting them / building the source array).
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement