code: public static String sha1(final InputStream inputStream) throws IOException, NoSuchAlgorithmException {
          MessageDigest md = MessageDigest.getInstance("SHA-1");
          byte[] bytes = new byte[8192];
          int byteCount;
          while ((byteCount = inputStream.read(bytes)) > 0) {
              md.update(bytes, 0, byteCount);
          }
  
          inputStream.close();
          return new String(encodeHex(md.digest()));
      }
docs: Utilitiy method to calculate sha1 based on given inputStream.
  
  @param inputStream InputStream of file to calculate sha1 for.
  @return the calculated sha1 for given stream.
  @throws IOException              thrown if there was issue getting stream content.
  @throws NoSuchAlgorithmException thrown if Sha-1 algorithm implementation is not supported by OS.