[
Is MD5 faster or SHA1? ]
It's implementation dependent:
|*|
[
Theoretically the MD5 algorithm would do less work than SHA1, but the design of MD5 itself determined that the algorithm cannot effectively exploit computation parallelism (i.e. cannot effectively utilize a multi-processor system; or processors that utilize instruction-level parallelism). While SHA1 would provide better opportunity for so.
This is part of the reason why in some implementations SHA1 would outperform MD5. ]
|*|
[
There are also processors that provide dedicated hardware acceleration support for SHA1.
When properly utilized, such implementations tend to easily outperform software based MD5 implementations:
[ Quote dr-js @ CE 2021-01-28 10:31 UTC:
https://security.stackexchange.com/a/95697
2021 update with OpenSSL 1.1.1d: now we see md5 is often slower on newer CPU, and for larger chunks:
[
## PC i7-1165G7 @ 2.80GHz (2020)
OpenSSL 1.1.1d 10 Sep 2019 / built on: Mon Dec 7 20:44:45 2020 UTC
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
md5 189018.70k 418310.85k 712090.28k 890189.14k 956293.12k 962560.00k
sha1 287134.62k 746529.17k 1474064.38k 1973607.08k 2197842.60k 2192179.20k
sha256 222301.71k 603962.47k 1213340.33k 1665262.59k 1849016.32k 1847388.84k
## Server AMD EPYC 7571 (2018)
OpenSSL 1.1.1d 10 Sep 2019 / built on: Mon Dec 7 20:44:45 2020 UTC
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
md5 93668.33k 213979.18k 378971.56k 467472.38k 501205.67k 504064.68k
sha1 165020.82k 442991.72k 888443.48k 1188591.62k 1319236.95k 1330080.43k
sha256 142886.55k 375612.63k 791567.70k 1095950.34k 1234381.48k 1246827.86k
## Server E5-2682 v4 @ 2.50GHz (2016)
OpenSSL 1.1.1d 10 Sep 2019 / built on: Mon Dec 7 20:44:45 2020 UTC
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
md5 101505.24k 207422.92k 393158.83k 453332.99k 527085.34k 490711.72k
sha1 98091.83k 249828.79k 389640.36k 675694.25k 686966.33k 721021.61k
sha256 55421.86k 130103.33k 251929.17k 302571.86k 296977.81k 338439.56k
] ]
Worth noticing that even SHA-256 could be faster than MD5 in such cases. ]
To put it in a simple (though not so accurate) statement:
|*| For high-end processors, SHA1 tends to be faster.
|*| For low-end processors, MD5 would be faster.
[ Quote Nyan @ CE 2020-12-10 10:18 UTC:
https://stackoverflow.com/a/64928816
Note that all of the above only applies to single buffer hashing (by far the most common use case). If you're fancy and computing multiple hashes in parallel, i.e. a multi-buffer SIMD approach, the behaviour changes somewhat. ]