wL iVTdZddlmZmZddlmZmZd dedeedefd Z d ede fd Z y) zFUtilities to efficiently compute the SHA 256 hash of a bunch of bytes.)BinaryIOOptional)sha1sha256Nfileobj chunk_sizereturnc||nd}t} |j|}|j||s |jS6)a Computes the sha256 hash of the given file object, by chunks of size `chunk_size`. Args: fileobj (file-like object): The File object to compute sha256 for, typically obtained with `open(path, "rb")` chunk_size (`int`, *optional*): The number of bytes to read from `fileobj` at once, defaults to 1MB. Returns: `bytes`: `fileobj`'s sha256 hash as bytes i)rreadupdatedigest)rr shachunks _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/huggingface_hub/utils/sha.py sha_fileobjrsK *5;J (C  Z( 5  ::< datact}|jd|jtt|j |jd|j||j S)aT Computes the git-sha1 hash of the given bytes, using the same algorithm as git. This is equivalent to running `git hash-object`. See https://git-scm.com/docs/git-hash-object for more details. Note: this method is valid for regular files. For LFS files, the proper git hash is supposed to be computed on the pointer file content, not the actual file content. However, for simplicity, we directly compare the sha256 of the LFS file content when we want to compare LFS files. Args: data (`bytes`): The data to compute the git-hash for. Returns: `str`: the git-hash of `data` as an hexadecimal string. Example: ```python >>> from huggingface_hub.utils.sha import git_hash >>> git_hash(b"Hello, World!") 'b45ef6fec89518d314f546fd6c3025367b721684' ``` sblob )rr strlenencode hexdigest)rrs rgit_hashr sX6 &CJJxJJs3t9~$$&'JJuJJt ==?r)N) __doc__typingrrinsecure_hashlibrrintbytesrrrrrr"s?L%*x}0 5 S r