o
    ‚ez  ã                   @   s@   d Z ddlmZ ddlmZmZ d
dedee defdd	„ZdS )zFUtilities to efficiently compute the SHA 256 hash of a bunch of bytes.é    )Úsha256)ÚBinaryIOÚOptionalNÚfileobjÚ
chunk_sizeÚreturnc                 C   s<   |dur|nd}t ƒ }	 |  |¡}| |¡ |s	 | ¡ S q)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Úchunk© r   úID:\Projects\ConvertPro\env\Lib\site-packages\huggingface_hub/utils/sha.pyÚsha_fileobj   s   

ûr   )N)	Ú__doc__Úhashlibr   Útypingr   r   ÚintÚbytesr   r   r   r   r   Ú<module>   s     