class IoUtils {

  public static byte[] getChecksum(final InputStream in)
      throws IOException, NoSuchAlgorithmException {
    final MessageDigest checksumGenerator = MessageDigest.getInstance("MD5");

    final DigestInputStream dis = new DigestInputStream(in, checksumGenerator);
    int readBytes = redirect(dis, new ByteArrayOutputStream());
    logger.debug("{} byte(s) read", readBytes);
    return checksumGenerator.digest();
  }

}