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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With