
    l$ez                     H    d Z ddlmZ ddlmZmZ d	dedee         defdZdS )
zFUtilities to efficiently compute the SHA 256 hash of a bunch of bytes.    )sha256)BinaryIOOptionalNfileobj
chunk_sizereturnc                     ||nd}t                      }	 |                     |          }|                    |           |sn.|                                S )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
    Ni   )r   readupdatedigest)r   r   shachunks       9lib/python3.11/site-packages/huggingface_hub/utils/sha.pysha_fileobjr      sc      *5;J
((CZ((

5 		
 ::<<    )N)	__doc__hashlibr   typingr   r   intbytesr    r   r   <module>r      sq    L L       % % % % % % % %  x}       r   