简体   繁体   中英

Is MD5 hash good enough to check if my file was transmitted properly

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 just random transmission errors, then md5 is good enough, it is very unlikely that such an error will produce the same hash. On the other hand if you want to protect yourself from an adversary manipulating bits with ill intent is, then md5 is outdated. If you communicate over an encrypted channel and its your data, then this shouldn't be a problem. But this needs to be kept in mind.

Also I want to add if performance is really that critical for you. Have you actually measured it? Usually sha256 is only 20-30% slower than md5. If that is still relevant, sure go for the faster option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM