
    Mhb                     f   U d dl mZ d dlmZmZ d dlmZ  ej                         Z	e
ed<    ej                         Ze
ed<    ej                         Ze
ed<    ej                          Ze
ed<    ej$                         Ze
ed<    ej(                         Ze
ed	<   d
edededefdZdedededefdZy)    )
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                    t        |      t        k7  rt        j                  d      t        |      t        k7  rt        j                  d      dt
        z  | z   }t        j                  dt        |            }t        j                  ||t        |      ||      }t        |dk(  dt        j                         t        j                  |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ress         v/var/www/pru.catia.catastroantioquia-mas.com/valormasv2/lib/python3.12/site-packages/nacl/bindings/crypto_secretbox.pyr   r      s     3x,,nn]++
5z00nn_--11G;F*CK8J


z63v;s
KC
3!8(#//BJF4J3455    r    c                    t        |      t        k7  rt        j                  d      t        |      t        k7  rt        j                  d      dt
        z  | z   }t        j                  dt        |            }t        j                  ||t        |      ||      }t        |dk(  dt        j                         t        j                  |t        |            }|t        d S )	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!   s         r"   r%   r%   9   s     3x,,nn]++
5z00nn_--44zAF)3v;7I

#
#Ivs6{E3
OC
q; 

9c&k2I/011r#   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"   <module>r4      s     # ! " "?!>!>!@ 3 @#B3#B#B#D S D"@#"@"@"B C B%FS%F%F%H s H!>!>!>!@ 3 @)C))+ "3 
6e 6E 6 6% 6422#2*/2
2r#   