code: static byte[] sha1(InputStream in) {
      try {
        MessageDigest md = MessageDigest.getInstance(SHA1_DIGEST); 
        byte[] buffer = new byte[4096];
        int bytes;
        while ( (bytes = in.read(buffer)) > 0) {
          md.update(buffer, 0, bytes);
        }
        return md.digest();
      }
      catch(NoSuchAlgorithmException | IOException e) {
        throw new InternalErrorException(e);
      }
    }
docs: Compute SHA-1 hash value for a given input stream.
  @param in Input stream
  @return SHA-1 hash value (array of 20 bytes).