HashHelper { public static String generateMd5Hash(String input) throws Exception { if (input == null) { throw new IllegalArgumentException("Input cannot be null"); } byte[] bytesOfMessage = input.getBytes("UTF-8"); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] hashBytes = md.digest(bytesOfMessage); StringBuilder sb = new StringBuilder(); for (int i = 0; i < hashBytes.length; i++) { sb.append(String.format("%02x", hashBytes[i] & 0xff)); } return sb.toString(); }  static String generateMd5Hash(String input);  }
@Test public void generateMd5HashTest() throws Exception { long timestamp = DatetimeHelper.getTimestamp(); assertEquals(true, timestamp > 0); assertTrue(HashHelper.generateMd5Hash("1234567890").contentEquals("e807f1fcf82d132f9bb018ca6738a19f")); }