o
    5h                     @   sL   d dl mZmZmZ ddlmZ ddlmZmZ G dd deZ	dd Z
d	S )
    )bordis_bytestobytes   )	cSHAKE128)_encode_str_right_encodec                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )	TupleHashz\A Tuple hash object.
    Do not instantiate directly.
    Use the :func:`new` function.
    c                 C   s    || _ |d|d| _d | _d S )N    s	   TupleHash)digest_size_new_cshake_digest)selfcustomcshaker    r   l/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/Crypto/Hash/TupleHash128.py__init__+   s   
zTupleHash.__init__c                 G   s@   | j dur	td|D ]}t|std| jt| q| S )zAuthenticate the next tuple of byte strings.
        TupleHash guarantees the logical separation between each byte string.

        Args:
            data (bytes/bytearray/memoryview): One or more items to hash.
        Nz6You cannot call 'update' after 'digest' or 'hexdigest'z#You can only call 'update' on bytes)r   	TypeErrorr   r   updater   )r   dataitemr   r   r   r   2   s   
zTupleHash.updatec                 C   s6   | j du r| jt| jd  | j| j| _ | j S )zReturn the **binary** (non-printable) digest of the tuple of byte strings.

        :return: The hash digest. Binary form.
        :rtype: byte string
        N   )r   r   r   r   r   readr   r   r   r   digestD   s   
zTupleHash.digestc                 C   s   d dd t|  D S )zReturn the **printable** digest of the tuple of byte strings.

        :return: The hash digest. Hexadecimal encoded.
        :rtype: string
         c                 S   s   g | ]}d t | qS )z%02x)r   ).0xr   r   r   
<listcomp>X   s    z'TupleHash.hexdigest.<locals>.<listcomp>)jointupler   r   r   r   r   	hexdigestQ   s   zTupleHash.hexdigestc                 K   s(   d|vrd|vr| j |d< tdi |S )zNReturn a new instance of a TupleHash object.
        See :func:`new`.
        digest_bytesdigest_bitsNr   )r   new)r   kwargsr   r   r   r&   Z   s   
zTupleHash.newN)	__name__
__module____qualname____doc__r   r   r   r#   r&   r   r   r   r   r	   %   s    	r	   c                  K   s   |  dd}|  dd}d||fvrtdd||fkrd}|dur+|dk r*tdn|dk s3|d r7td	|d }|  d
d}t|t|S )a  Create a new TupleHash128 object.

    Args:
       digest_bytes (integer):
        Optional. The size of the digest, in bytes.
        Default is 64. Minimum is 8.
       digest_bits (integer):
        Optional and alternative to ``digest_bytes``.
        The size of the digest, in bits (and in steps of 8).
        Default is 512. Minimum is 64.
       custom (bytes):
        Optional.
        A customization bytestring (``S`` in SP 800-185).

    :Return: A :class:`TupleHash` object
    r$   Nr%   z*Only one digest parameter must be provided)NN@   r   z!'digest_bytes' must be at least 8z0'digest_bytes' must be at least 64 in steps of 8r   r
   )popr   
ValueErrorr	   r   )r'   r$   r%   r   r   r   r   r&   e   s   r&   N)Crypto.Util.py3compatr   r   r   r   r   r   r   objectr	   r&   r   r   r   r   <module>   s
   @