Programming Tips - Java: make an MD5 hash (digest)

Date: 2022sep22 Language: Java Q. Java: make an MD5 hash (digest) A. Warning: MD5 isn't cryptographically secure any more. But it still has uses.
import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public static String makeMD5(final String thingOne, final String thingTwo) { MessageDigest md; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException ex) { 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 }