code: public static String createHash(final InputStream inputStream, final String algorithm) {
          checkNotNull("inputStream", inputStream);
          checkNotNull("algorithm", algorithm);
          try {
              final MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
              try (final BufferedInputStream in = new BufferedInputStream(inputStream)) {
                  final byte[] buf = new byte[1024];
                  int count = 0;
                  while ((count = in.read(buf)) > -1) {
                      messageDigest.update(buf, 0, count);
                  }
              }
              return encodeHex(messageDigest.digest());
          } catch (final NoSuchAlgorithmException | IOException ex) {
              throw new RuntimeException(ex);
          }
      }
docs: Creates a HEX encoded hash from a stream.
  
  @param inputStream
  Stream to create a hash for - Cannot be <code>null</code>.
  @param algorithm
  Hash algorithm like "MD5" or "SHA" - Cannot be <code>null</code>.
  
  @return HEX encoded hash.