The difference is also clear in pure JavaScript implementations — JS doesn't have native 64-bit integer operations yet, so SHA-512 is slower there:
SHA-256 - 103.17 MiB/s
SHA-512 - 34.29 MiB/s
Note that since SHA-512 eats 128-byte blocks, while SHA-256 64-byte blocks, hashing very short strings may be faster with SHA-256 even on 64-bit platforms (the same applies to BLAKE2).
Do you mean because of the lack of low level control/bit manipulation, vs C/asm, or something else? I would have guessed it was about the same as any interpreted/jitted higher level language (python/php/c#/java).
SHA 224/384 are just truncated forms of the same algorithm as SHA 256/512, respectively. (With different initial constants, as well, but that doesn't matter for this.)
SHA-512 is in fact slower per iteration, but uses twice the block size as SHA-256. For hashing e.g. files, the per-byte number is what matters. But when doing hash trees, for example, the per-iteration performance is what matters and SHA-256 wins out there.
14 comments
[ 2.9 ms ] story [ 62.1 ms ] threadThe difference is also clear in pure JavaScript implementations — JS doesn't have native 64-bit integer operations yet, so SHA-512 is slower there:
Note that since SHA-512 eats 128-byte blocks, while SHA-256 64-byte blocks, hashing very short strings may be faster with SHA-256 even on 64-bit platforms (the same applies to BLAKE2).Is not JS cryptography a bad idea?
SHA-512 is in fact slower per iteration, but uses twice the block size as SHA-256. For hashing e.g. files, the per-byte number is what matters. But when doing hash trees, for example, the per-iteration performance is what matters and SHA-256 wins out there.