o
    ç÷¡gb  ã                   @   sÂ   U d dl mZ d dlmZmZ d dlmZ e ¡ Z	e
ed< e ¡ Ze
ed< e ¡ Ze
ed< e ¡ Ze
ed< e ¡ Ze
ed< e ¡ Ze
ed	< d
edededefdd„Zdedededefdd„ZdS )é    )Ú
exceptions)ÚffiÚlib)ÚensureÚcrypto_secretbox_KEYBYTESÚcrypto_secretbox_NONCEBYTESÚcrypto_secretbox_ZEROBYTESÚcrypto_secretbox_BOXZEROBYTESÚcrypto_secretbox_MACBYTESÚ!crypto_secretbox_MESSAGEBYTES_MAXÚmessageÚnonceÚkeyÚreturnc                 C   óŽ   t |ƒtkrt d¡‚t |ƒtkrt d¡‚dt |  }t dt |ƒ¡}t 	||t |ƒ||¡}t
|dkdtjd� t |t |ƒ¡}|td… S )	zÆ
    Encrypts and returns the message ``message`` with the secret ``key`` and
    the nonce ``nonce``.

    :param message: bytes
    :param nonce: bytes
    :param key: bytes
    :rtype: bytes
    úInvalid keyúInvalid nonceó    úunsigned char[]r   zEncryption failed©ÚraisingN)Úlenr   ÚexcÚ
ValueErrorr   r   r   Únewr   Úcrypto_secretboxr   ÚCryptoErrorÚbufferr	   )r   r   r   ÚpaddedÚ
ciphertextÚres© r!   úI/usr/local/lib/python3.10/dist-packages/nacl/bindings/crypto_secretbox.pyr      s   


r   r   c                 C   r   )	zÕ
    Decrypt and returns the encrypted message ``ciphertext`` with the secret
    ``key`` and the nonce ``nonce``.

    :param ciphertext: bytes
    :param nonce: bytes
    :param key: bytes
    :rtype: bytes
    r   r   r   r   r   z1Decryption failed. Ciphertext failed verificationr   N)r   r   r   r   r   r	   r   r   r   Úcrypto_secretbox_openr   r   r   r   )r   r   r   r   Ú	plaintextr    r!   r!   r"   r#   9   s   

ýr#   N)Únaclr   r   Únacl._sodiumr   r   Únacl.exceptionsr   Úcrypto_secretbox_keybytesr   ÚintÚ__annotations__Úcrypto_secretbox_noncebytesr   Úcrypto_secretbox_zerobytesr   Úcrypto_secretbox_boxzerobytesr	   Úcrypto_secretbox_macbytesr
   Ú!crypto_secretbox_messagebytes_maxr   Úbytesr   r#   r!   r!   r!   r"   Ú<module>   s(   
ÿÿÿÿþ