import hashlib


def _file_hash(filename: str) -> str:
  """Compute the hash of a file.

  Args:
    filename: the filename to hash.

  Returns:
    The hash hex string of the file contents.
  """
  sha256_hash = hashlib.sha256()
  with open(filename, "rb") as f:
    # Read and update hash string value in blocks of 4K
    while True:
      l: bytes = f.read(4096)
      if not l:
        return sha256_hash.hexdigest()
      sha256_hash.update(l)