U
    Å9%ez  ã                   @   s<   d Z ddlmZ ddlmZmZ deee edœ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k	r|nd}t ƒ }|  |¡}| |¡ |sq2q| ¡ 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Úchunk© r   úX/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/huggingface_hub/utils/sha.pyÚsha_fileobj   s    

r   )N)	Ú__doc__Úhashlibr   Útypingr   r   ÚintÚbytesr   r   r   r   r   Ú<module>   s   