U
    ÎZj%	  ã                   @   sœ   d dl Z d dlmZmZmZ d dlZd dlmZ eddd�ZG dd„ de	ƒZ
G dd	„ d	ƒZe	ed
œdd„Zdee	dœdd„Zejfee	eje	dœdd„ZdS )é    N)ÚSupportsBytesÚTypeÚTypeVar)ÚencodingÚ_EncryptedMessageÚEncryptedMessage)Úboundc                   @   sd   e Zd ZU dZeed< eed< eee eeeedœdd„ƒZ	e
edœdd	„ƒZe
edœd
d„ƒZdS )r   ze
    A bytes subclass that holds a messaged that has been encrypted by a
    :class:`SecretBox`.
    Ú_nonceÚ_ciphertext)ÚclsÚnonceÚ
ciphertextÚcombinedÚreturnc                 C   s   | |ƒ}||_ ||_|S ©N)r	   r
   )r   r   r   r   Úobj© r   úM/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/nacl/utils.pyÚ_from_parts"   s    zEncryptedMessage._from_parts)r   c                 C   s   | j S )zX
        The nonce used during the encryption of the :class:`EncryptedMessage`.
        )r	   ©Úselfr   r   r   r   .   s    zEncryptedMessage.noncec                 C   s   | j S )zP
        The ciphertext contained within the :class:`EncryptedMessage`.
        )r
   r   r   r   r   r   5   s    zEncryptedMessage.ciphertextN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚbytesÚ__annotations__Úclassmethodr   r   r   Úpropertyr   r   r   r   r   r   r      s   
ûc                   @   s   e Zd Zeedœdd„ZdS )ÚStringFixer)r   r   c                 C   s   t |  ¡ ƒS r   )ÚstrÚ	__bytes__r   r   r   r   Ú__str__>   s    zStringFixer.__str__N)r   r   r   r   r    r"   r   r   r   r   r   =   s   r   )Úbytes_inr   c                 C   s
   |   d¡S )NÚascii)Údecode)r#   r   r   r   Úbytes_as_stringB   s    r&   é    )Úsizer   c                 C   s
   t  | ¡S r   )ÚosÚurandom)r(   r   r   r   ÚrandomF   s    r+   )r(   ÚseedÚencoderr   c                 C   s   t j | |¡}| |¡S )zê
    Returns ``size`` number of deterministically generated pseudorandom bytes
    from a seed

    :param size: int
    :param seed: bytes
    :param encoder: The encoder class used to encode the produced bytes
    :rtype: bytes
    )ÚnaclZbindingsZrandombytes_buf_deterministicÚencode)r(   r,   r-   Úraw_datar   r   r   Úrandombytes_deterministicJ   s    r1   )r'   )r)   Útypingr   r   r   Znacl.bindingsr.   r   r   r   r   r   r    r&   Úintr+   Z
RawEncoderZEncoderr1   r   r   r   r   Ú<module>   s   $ÿ  þ