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

Date: 2022sep22 Language: Java Q. Java: make a MD5 hash (digest) A. Warning: MD5 isn't cryptographically secure any more. But it still has uses.
import; import; public static String makeMD5(final String thingOne, final String thingTwo) { MessageDigest md; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException ex) { // Every implementation of the Java platform is required to support // the following standard MessageDigest algorithms: MD5 SHA-1 SHA-256 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 }