a
   ]                   @   s|   d dl mZmZmZ d dlZd dlZd dlZd dlmZ G dd de	Z
G dd deZdd	 ZdddZejfddZdS )    )absolute_importdivisionprint_functionN)encodingc                   @   s4   e Zd ZdZedd Zedd Zedd ZdS )	EncryptedMessageze
    A bytes subclass that holds a messaged that has been encrypted by a
    :class:`SecretBox`.
    c                 C   s   | |}||_ ||_|S N)_nonce_ciphertext)clsnonce
ciphertextZcombinedobj r   ./usr/lib/python3.9/site-packages/nacl/utils.py_from_parts   s    zEncryptedMessage._from_partsc                 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   -   s    zEncryptedMessage.ciphertextN)	__name__
__module____qualname____doc__classmethodr   propertyr   r   r   r   r   r   r      s   

r   c                   @   s   e Zd Zdd ZdS )StringFixerc                 C   s   t jrt|  S |  S d S r   )sixPY3str	__bytes__r   r   r   r   __str__7   s    zStringFixer.__str__N)r   r   r   r   r   r   r   r   r   5   s   r   c                 C   s   t jr| dS | S d S )Nascii)r   r   decode)Zbytes_inr   r   r   bytes_as_string>   s    
r!       c                 C   s
   t | S r   )osurandom)sizer   r   r   randomE   s    r&   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%   Zseedencoderraw_datar   r   r   randombytes_deterministicI   s    
r+   )r"   )Z
__future__r   r   r   r#   r   Znacl.bindingsr'   r   bytesr   objectr   r!   r&   Z
RawEncoderr+   r   r   r   r   <module>   s   	
