1

I have to transfer my file from one server to another. An automated script will be doing transfer every night at 12 am. I want to compare the the md5 hash of the file before transmission and md5 hash of file after transmission. Is md5 hash good emough for this purpose?

Or should I be using sha256?

My main concern is that sha256 is much slower than md5. My file size would be around 1 GB per file.

Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95
OVERTHETOP
  • 31
  • 2
  • Reference about speed: https://stackoverflow.com/questions/2722943/is-calculating-an-md5-hash-less-cpu-intensive-than-sha-family-functions – Chris Aug 07 '22 at 09:38
  • More discussion about md5 vs sha256 https://stackoverflow.com/questions/14139727/sha-256-or-md5-for-file-integrity – Chris Aug 07 '22 at 09:38

1 Answers1

4

I would say yes. The main benefit of sha256 is its security aspect. If your concern are random transmission errors, then md5 is good enough. It is very unlikely that an error will produce the same hash.

On the other hand, if you want to protect yourself from somebody manipulating bits with ill intent, then md5 is not enough. If you communicate over an encrypted channel and its your data, then this shouldn't be a problem, otherwise this needs to be considered.

Also I would double check your performance requirements. For good implementations, today, sha256 is only 20-30% slower than md5. If its bigger than that, maybe you need to change your implementation. If it still remains a bottleneck, sure go for the faster option.

Chris
  • 2,461
  • 1
  • 23
  • 29