IoUtils { public static String getChecksumAsString(final InputStream in) throws IOException, NoSuchAlgorithmException { final byte[] bytes = getChecksum(in); return BaseEncoding.base64().encode(bytes); }  static void tryFlush(final Object... flushable); static int stream(final InputStream in, final StreamConsumer consumer); static int redirect(final InputStream from, final OutputStream to); static int redirect(final Reader from, final Writer to); static byte[] from(
      final InputStream in); static String from(
      final Reader reader); static byte[] getChecksum(final InputStream in); static String getChecksumAsString(final InputStream in);  }
@Test public void testGetChecksumAsString() throws NoSuchAlgorithmException, IOException { final Object[][] testParameters = new Object[][] { {new ByteArrayInputStream(new byte[] {1, 2, 3}), "Uonfc331cyb83SJZevsfrA=="}, {new ByteArrayInputStream(new byte[] {4, 5, 6, 7, 8}), "ounpxAX8tCgIz6Dq8lJ8Nw=="}, {new ByteArrayInputStream(new byte[] {9, 10, 11, 12, 13, 14, 15}), "sMsYm49mZGqQKjnDDyPDow=="}}; for (final Object[] testParameter : testParameters) { String expected = (String) testParameter[1]; InputStream in = (InputStream) testParameter[0]; assertEquals(expected, IoUtils.getChecksumAsString(in)); } }