
    ,h                     \    d dl mZ d dlmZ ddlmZ d ZdZdZdZ	dZ
 G d	 d
e      ZddZy)    )long_to_bytes)bchr   )TurboSHAKE128c                 R    | dk(  ryt        |       }|t        t        |            z   S )Nr       )r   r   len)xSs     \/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/Crypto/Hash/KangarooTwelve.py_length_encoder   $   s)    AvaAtCF|             c                   *    e Zd ZdZd Zd Zd ZddZy)K12_XOFzeA KangarooTwelve hash object.
    Do not instantiate directly.
    Use the :func:`new` function.
    c                    |d k(  rd}|t        t        |            z   | _        t        | _        d | _        t        j                  d      | _        d| _	        d | _
        d| _        d| _        |r| j                  |       y y )Nr   r   domainr   )r   r	   _custom	SHORT_MSG_state_paddingr   new_hash1_length1_hash2_length2_ctrupdateselfdatacustoms      r   __init__zK12_XOF.__init__9   sy    T>Fs6{ ;; $''q1  	KK r   c                    | j                   t        k(  rt        d      | j                   t        k(  rb| j                  t        |      z   }|t        | j                        z   dk  r$|| _        | j                  j                  |       | S t        | _         | j                   t        k(  rt        |      }| j                  dk  sJ t        t        |      d| j                  z
        }| j                  j                  |d|        | xj                  |z  c_        | j                  dk  r| S | j                  dk(  sJ d}| j                  j                  |       | xj                  dz  c_        t        j                  d      | _        d| _        d	| _        t"        | _         | j                  ||d       S | j                   t"        k(  sJ d}t        |      }t        |      }||k  rt        |dz   | j                  z
  |      }| j                  j                  |||        | xj                  ||z
  z  c_        |}| j                  dk(  r| j                  j%                  d
      }	| j                  j                  |	       | xj                  d
z  c_        | j                  j'                          d| _        | xj                   d	z  c_        ||k  r| S )a
  Hash the next piece of data.

        .. note::
            For better performance, submit chunks with a length multiple of 8192 bytes.

        Args:
            data (byte string/byte array/memoryview): The next chunk of the
              message to hash.
        z/You cannot call 'update' after the first 'read'i    Ns                r   r   r       )r   	SQUEEZING	TypeErrorr   r   r	   r   r   r!   LONG_MSG_S0
memoryviewminr   r   r   r   r    LONG_MSG_SXread_reset)
r#   r$   next_lengthdata_memdtcdividerindexlen_data	new_indexcv_is
             r   r!   zK12_XOF.updateQ   sP    ;;)#MNN;;)#--#d)3KS..$6 +""4( &DK;;+%!$'H==4'(c$i!56CKKx~.MMS M}}t# ==D()+GKKw'MMQM'++48DKDMDI%DK;;x~.. {{k)*t9 d#hEDL4==8(CIKKxi89MMY..ME}}${{''+""4(#""$ !		Q	 h r   c                    d}| j                   t        k(  r7| j                  j                  | j                         d| _        t        | _         | j                   t        k(  r2| j                  | j                         d}| j                   t        k(  sJ | j                   t        k(  r|s| j                  | j                         | j                  dkD  r| j                  j                  d      }| j                  j                  |       | xj                  dz  c_        | j                  j                          d| _	        | xj                  dz  c_        t        | j                  dz
        dz   }| j                  j                  |       d| _        t        | _         | j
                  | j                  _        | j                  j                  |      S )	ad  
        Produce more bytes of the digest.

        .. note::
            You cannot use :meth:`update` anymore after the first call to
            :meth:`read`.

        Args:
            length (integer): the amount of bytes this method must return

        :return: the next piece of XOF output (of the given length)
        :rtype: byte string
        F   Tr   r*   r   s      )r   r   r   r!   r   r   r+   r-   r0   r   r   r1   r   r2   r    r   _domain)r#   lengthcustom_was_consumedr:   trailers        r   r1   zK12_XOF.read   sL    $;;)#KKt||, DM#DK;;+%KK%"&;;+-.;;+%&DLL) }}q {{''+""4(#""$ !		Q	$TYY]3kAGKKw' DM#DK"mm{{''r   Nc                 &     t        |       ||      S )N)typer"   s      r   r   zK12_XOF.new   s    tDz$''r   )Nr   )__name__
__module____qualname____doc__r&   r!   r1   r    r   r   r   r   3   s    
0GR/(b(r   r   Nc                     t        | |      S )ag  Return a fresh instance of a KangarooTwelve object.

    Args:
       data (bytes/bytearray/memoryview):
        Optional.
        The very first chunk of the message to hash.
        It is equivalent to an early call to :meth:`update`.
       custom (bytes):
        Optional.
        A customization byte string.

    :Return: A :class:`K12_XOF` object
    )r   )r$   r%   s     r   r   r      s     4  r   )NN)Crypto.Util.numberr   Crypto.Util.py3compatr    r   r   r   r-   r0   r+   objectr   r   rH   r   r   <module>rN      s?   > - &  		Y(f Y(x!r   