Java - Hash algorithms - Fastest implementations

前端 未结 6 777
一个人的身影
一个人的身影 2020-12-23 09:54

I want to know what is the best and fastest implementation of hash algorithms for Java especially MD5 and SHA-2 512 (SHA512) or 256. I want a function to get a string as an

6条回答
  •  -上瘾入骨i
    2020-12-23 10:13

    Consider BLAKE2 which is faster and more secure than the hashes mentioned above.

    MD5, SHA-1, SHA256, and SHA-512 are susceptible to length-extension.

    MD5 and SHA-1 are vulnerable to collisions.

    MD5 is vulnerable to chosen-prefix collisions.

    SHA-3 and BLAKE2 have no known security issues and can generate digests of varying length.

    SHA-3 is fastest when implemented in hardware; BLAKE2 is fastest when using software implementations.

    BLAKE2b is optimized for 64-bit platforms and produces digests of any size between 1 and 64 bytes.

    BLAKE2s is optimized for 8 to 32-bit platforms and produces digests of any size between 1 and 32 bytes.

    Here are benchmarks for AES, MD5, SHA-256, and BLAKE2b.

    https://blake2.net/

    https://www.cryptopp.com/benchmarks.html

    In the first link, BLAKE2b (947 Mbits) is much faster than SHA-256 (413 Mbits) and MD5 (632 Mbits).

    In the second link, AES-256 CBC (805 Mbits) and BLAKE2b (776 Mbits) are about equal in speed and faster then SHA-256 (275 Mbits) and MD5 (602) Mbits.

提交回复
热议问题