o
    n~b
                     @   sd   d dl mZ d dlmZmZmZmZmZmZm	Z	 eddZ
G dd deZd
dd	ZejZejZdS )    bord)load_pycryptodome_raw_libVoidPointerSmartPointercreate_string_bufferget_raw_bufferc_size_tc_uint8_ptrzCryptodome.Hash._RIPEMD160a  
                        int ripemd160_init(void **shaState);
                        int ripemd160_destroy(void *shaState);
                        int ripemd160_update(void *hs,
                                          const uint8_t *buf,
                                          size_t len);
                        int ripemd160_digest(const void *shaState,
                                          uint8_t digest[20]);
                        int ripemd160_copy(const void *src, void *dst);
                        c                   @   sP   e Zd ZdZdZdZdZdddZdd	 Zd
d Z	dd Z
dd ZdddZdS )RIPEMD160Hasha  A RIPEMD-160 hash object.
    Do not instantiate directly.
    Use the :func:`new` function.

    :ivar oid: ASN.1 Object ID
    :vartype oid: string

    :ivar block_size: the size in bytes of the internal message block,
                      input to the compression function
    :vartype block_size: integer

    :ivar digest_size: the size in bytes of the resulting hash
    :vartype digest_size: integer
       @   z1.3.36.3.2.1Nc                 C   sL   t  }t| }|rtd| t| tj| _|r$| 	| d S d S )Nz&Error %d while instantiating RIPEMD160)
r   _raw_ripemd160_libZripemd160_initZ
address_of
ValueErrorr   getZripemd160_destroy_stateupdate)selfdatastateresult r   D/usr/local/lib/python3.10/dist-packages/Cryptodome/Hash/RIPEMD160.py__init__L   s   zRIPEMD160Hash.__init__c                 C   s4   t | j t|tt|}|rtd| dS )zContinue hashing of a message by consuming the next chunk of data.

        Args:
            data (byte string/byte array/memoryview): The next chunk of the message being hashed.
        &Error %d while instantiating ripemd160N)r   Zripemd160_updater   r   r
   r	   lenr   )r   r   r   r   r   r   r   W   s   
zRIPEMD160Hash.updatec                 C   s4   t | j}t| j |}|rtd| t|S )zReturn the **binary** (non-printable) digest of the message that has been hashed so far.

        :return: The hash digest, computed over the data processed so far.
                 Binary form.
        :rtype: byte string
        r   )r   digest_sizer   Zripemd160_digestr   r   r   r   )r   Zbfrr   r   r   r   digeste   s   
zRIPEMD160Hash.digestc                 C   s   d dd |  D S )zReturn the **printable** digest of the message that has been hashed so far.

        :return: The hash digest, computed over the data processed so far.
                 Hexadecimal encoded.
        :rtype: string
         c                 S   s   g | ]}d t | qS )z%02xr   ).0xr   r   r   
<listcomp>~   s    z+RIPEMD160Hash.hexdigest.<locals>.<listcomp>)joinr   )r   r   r   r   	hexdigestv   s   zRIPEMD160Hash.hexdigestc                 C   s2   t  }t| j |j }|rtd| |S )a4  Return a copy ("clone") of the hash object.

        The copy will have the same internal state as the original hash
        object.
        This can be used to efficiently compute the digests of strings that
        share a common initial substring.

        :return: A hash object of the same type
        z Error %d while copying ripemd160)r   r   Zripemd160_copyr   r   r   )r   cloner   r   r   r   copy   s   zRIPEMD160Hash.copyc                 C   s   t |S )z&Create a fresh RIPEMD-160 hash object.)r   )r   r   r   r   r   new   s   zRIPEMD160Hash.newN)__name__
__module____qualname____doc__r   
block_sizeoidr   r   r   r#   r%   r&   r   r   r   r   r   5   s    

r   Nc                 C   s   t  | S )a#  Create a new hash object.

    :parameter data:
        Optional. The very first chunk of the message to hash.
        It is equivalent to an early call to :meth:`RIPEMD160Hash.update`.
    :type data: byte string/byte array/memoryview

    :Return: A :class:`RIPEMD160Hash` hash object
    )r   r&   )r   r   r   r   r&      s   r&   r'   )ZCryptodome.Util.py3compatr   ZCryptodome.Util._raw_apir   r   r   r   r   r	   r
   r   objectr   r&   r   r,   r   r   r   r   <module>   s   $
c
