[docs]defhash_file(path:Path,algo:str="sha256")->str:""" Hash a file by content and return the hex digest. Reads the file in chunks so large files do not require loading the entire content into memory. Args: path: Path to the file to hash. algo: Hash algorithm name accepted by hashlib (default "sha256"). Returns: Lowercase hex digest string e.g. "2e7698fc5e3744fd...". Raises: FileNotFoundError: If path does not exist. """h=hashlib.new(algo)withpath.open("rb")asf:forchunkiniter(lambda:f.read(BUF_SIZE),b""):h.update(chunk)returnh.hexdigest()