o
    Zh                     @   s@   d Z ddlmZmZ ddl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.    )BinaryIOOptional   )sha256N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   P/var/www/html/lang_env/lib/python3.10/site-packages/huggingface_hub/utils/sha.pysha_fileobj   s   

r   )N)	__doc__typingr   r   Zinsecure_hashlibr   intbytesr   r   r   r   r   <module>   s     