Programming Tips - Java: Make a SHA-3 hash (digest)

Date: 2025aug21 Language: Java Q. Java: Make a SHA-3 hash (digest) A.
import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public static String makeSha3(final String thingOne, final String thingTwo) { MessageDigest md; try { md = MessageDigest.getInstance("SHA3-256"); // Also SHA3-224, SHA3-384 and SHA3-512 } catch (NoSuchAlgorithmException ex) { // Depends on your Java version if this happens return ""; } md.update(thingOne.getBytes()); md.update(thingTwo.getBytes()); final byte byteData[] = md.digest(); return Hex.toHexString(byteData); // This function is available elsewhere on davekb }