0

As the question says, if I'm downloading let's say a zip file on different hardware & devices, mobile/windows/mac. Can I be certain that for example an MD5 or SHA hash will be identical across all platforms. My worry is file system/differences between platforms when unzipping this folder.

Ideally I'm hashing through all files in alphabetical order & combining them, and then checking that against a database hash string to ensure contents are never changed whenever the application runs.

Prodigle
  • 1,757
  • 12
  • 23
  • Yes, a correctly implemented hash should be platform independent. – Martin Costello Apr 14 '22 at 09:52
  • The hash of a file is derived from the contents (raw bytes) of the file, any implementation that's compliant with the MD5 (RFC 1321) (or any hashing algorithm) specification will produce the exact same output given the exact same input, no matter what system they are ran on. I'd also like to add that `GetHashCode` is **not** platform independent, you will get differing results, even sometimes if ran on the same system by two different runtime versions – MindSwipe Apr 14 '22 at 10:27

1 Answers1

2

Yes for md5 and sha. Implementations of common public used hashfunctions produce the expected output for all these systems.

I can additionally say that I have had this in working correctly in production with the combination of iphone + windows.

This also has been asked and answered already so id say is a duplicate: Is a hash function (e.g. SHA) platform independent?

t0b4cc0
  • 319
  • 4
  • 19