ChecksumUtil { public String generateChecksumBase64(String string) { return new String(Base64.encodeBase64(generateChecksumBytes(string))); } ChecksumUtil(Algorithm alg); String generateChecksum(File file); String generateChecksum(InputStream inStream); String generateChecksum(String string); String generateChecksumBase64(String string); static DigestInputStream wrapStream(InputStream inStream,
                                               Algorithm algorithm); static String getChecksum(DigestInputStream digestStream); static byte[] getChecksumBytes(DigestInputStream digestStream); static String checksumBytesToString(byte[] digestBytes); static byte[] hexStringToByteArray(String s); static String convertToBase64Encoding(String hexEncodedChecksum);  }
@Test public void testGenerateChecksumBase64() throws Exception { ChecksumUtil util = new ChecksumUtil(Algorithm.MD5); String base64Checksum = util.generateChecksumBase64(shortContent); assertEquals(shortContentMd5Base64, base64Checksum); }