ParseDigestUtils { public static String md5(String string) { MessageDigest digester; try { digester = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } digester.update(string.getBytes()); byte[] digest = digester.digest(); return toHex(digest); } private  ParseDigestUtils(); static String md5(String string);  }
@Test public void testMD5() { Map<String, String> stringToMD5 = new HashMap<>(); stringToMD5.put("grantland", "66ad19754cd2edcc20c3221a5488a599"); stringToMD5.put("nikita", "b00a50c448238a71ed479f81fa4d9066"); stringToMD5.put("1337", "e48e13207341b6bffb7fb1622282247b"); stringToMD5.put("I am a potato", "2e832e16f60587842c7e4080142dbeca"); for (Map.Entry<String, String> entry : stringToMD5.entrySet()) { String md5 = ParseDigestUtils.md5(entry.getKey()); assertEquals(entry.getValue(), md5); } }