Checksum { public static String getMD5Checksum(String string) throws Exception { MessageDigest digest = java.security.MessageDigest.getInstance("MD5"); digest.update(string.getBytes()); byte messageDigest[] = digest.digest(); return getHex(messageDigest); }  static String getHex(byte[] raw); static String getMD5Checksum(String string); static String getMD5Checksum(File file);  }
@Test public void testgetMD5Checksum() throws Exception { String md5 = Checksum.getMD5Checksum("foo"); assertEquals(md5, "ACBD18DB4CC2F85CEDEF654FCCC4A4D8"); }
@Test public void testgetMD5ChecksumDir() throws Exception { File directory = new File(".", ""); String md5 = Checksum.getMD5Checksum(directory); assertTrue(md5 == null); }