code: public static String sha1Hash(File file) throws IOException {
          try {
              DigestInputStream inputStream = new DigestInputStream(
                      new FileInputStream(file), MessageDigest.getInstance("SHA-1"));
              try {
                  byte[] buffer = new byte[4098];
                  while (inputStream.read(buffer) != -1) {
                      // Read the entire stream
                  }
                  return bytesToHex(inputStream.getMessageDigest().digest());
              } finally {
                  inputStream.close();
              }
          } catch (NoSuchAlgorithmException ex) {
              throw new IllegalStateException(ex);
          }
      }
docs: Generate a SHA.1 Hash for a given file.
  
  @param file the file to hash
  @return the hash value as a String
  @throws IOException if the file cannot be read