code: public static String getChecksum(InputStream in, String algo) throws NoSuchAlgorithmException,
                                                                 IOException {
  
      MessageDigest md = MessageDigest.getInstance(algo);
  
      DigestInputStream digestInputStream = new DigestInputStream(in, md);
      digestInputStream.on(true);
  
      while (digestInputStream.read() > -1) {
        digestInputStream.read();
      }
  
      byte[] bytes = digestInputStream.getMessageDigest().digest();
      return generateString(bytes);
    }
docs: Generates checksum for the InputStream.
  
  @param in
  stream to generate CheckSum
  @param algo
  algorithm name according to the
  {@literal
  <a href= "http://java.sun.com/j2se/1.4.2/docs/guide/security/CryptoSpec.html#AppA">
  Java Cryptography Architecture API Specification & Reference
  </a>
  }
  @return hexadecimal string checksun representation
  @throws NoSuchAlgorithmException
  @throws IOException