This chapter covers changes related to security in Java 9.
SHA-3 Hash Algorithms
Java 9 adds four SHA-3
(
https://en.wikipedia.org/wiki/SHA-3
) hash algorithms
to generate message digest: SHA3-224, SHA3-256, SHA3-384, and SHA3-512. Listing 13-1 shows an example of how to use the algorithm SHA3-224 to generate a message digest.
import org.apache.commons.codec.binary.Hex;
public class SHA3 {
public static void main(final String[] args) throws NoSuchAlgorithmException {
final MessageDigest instance = MessageDigest.getInstance("SHA3-224");
final byte[] digest = instance.digest("".getBytes());
System.out.println(Hex.encodeHexString(digest)); ...