Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

Without taking into account security, which hash function is the fastest one among the following:

MD5, SHA-1, SHA-2 (for various internal size), Keccak, and other… ?

share|improve this question
    
On what platform? And what kind of implementation? Some hashes need c with SIMD intrinsics to shine, some are okay with plain c. Some require 64 bit CPUs, some excel in hardware (ASIC or FPGA). There is no single fastest hash. –  CodesInChaos Oct 10 '13 at 7:40
    
Then there are treed modes which will speed up some hashes more than others. For example I'd expect a much bigger speedup due to treeing+SIMD for MD5 than for Blake, since the latter already uses SIMD within a single instance. –  CodesInChaos Oct 10 '13 at 7:42
    
And finally if you don't care about security, you can simply decrease the security margin. For example if you decrease Blake2's number of rounds to prevent the best known attack, you'd get another factor 3 or so speedup. –  CodesInChaos Oct 10 '13 at 7:44
    
The question as currently stated isn't tight enough to give you the answer you want. If you don't care about security, then the fastest hash function is to return an empty hash (or $h(x)=0$ if you want to $\mathrm{length}(h(x))>0$). I know this is a stupid answer, but the point is you can't ignore the security. If you provide a detail on how much security is required then people can explain which variant of which algorithm is the best for you. –  figlesquidge Nov 7 '13 at 18:26
add comment

closed as too broad by rath, AFS, DrLecter, e-sushi, Gilles Nov 15 '13 at 19:48

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

The performance of the hash depends on the environment it is used in.

Keccak excels in ASIC type hardware designs, whereas Blake and Skein excel in x86 and x86-64 environments.

MD5 is still quite fast in software, but newer algorithms take advantage of SIMD instructions on newer processors.

There is also the question of performance on a per invocation basis or on a per byte basis for larger messages. Keccak also has different speeds that depend on the security level (and message size).

SHA512 operates on a maximum message size of 885 bits before more than 1 invocation of the hash is required to process it, whereas SHA256 has a maximum size of 447 bits. That means a hash of a 128-bit message will be faster on SHA256, but a hash on a 128MB message may be quite faster with SHA512. SHA512 is about 50% faster on larger messages, but can be half as fast on small ones. This type of performance will vary with CPU type.

Performance comparisons with multiple message sizes and CPU types can be found here: http://bench.cr.yp.to/results-sha3.html

share|improve this answer
    
It's probably reasonable to mention BLAKE2b, which seems to be faster in software than even MD5 due to its design around SIMD processors. –  Stephen Touset Oct 10 '13 at 7:15
    
Indeed, Blake2 is about 30% faster than Blake due to the reduced round count, and a bit faster still on longer messages due to how it handles the conversion of message bits to words. It is also much more secure than MD5. –  Richie Frame Oct 10 '13 at 7:43
    
@StephenTouset One needs to be careful about such comparison. The devil is in the details. At least it's faster when comparing with sequential MD5 on 64 bit Intel CPUs, which is pretty much its optimum case. 32 bit, non intel (including AMD), or treeing MD5 will improve MD5s performance relatively to Blake2b. On the other hand you can cut the number of rounds by a factor 3 or so to get a version of Blake2 that's still much stronger than MD5. –  CodesInChaos Oct 10 '13 at 7:48
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.