| Server IP : 138.197.176.125 / Your IP : 216.73.217.54 Web Server : Apache/2.4.41 (Ubuntu) System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/nacl/bindings/__pycache__/ |
Upload File : |
U
�֫[0 � @ s� d dl mZmZmZ d dlmZ d dlmZm Z d dl
mZ e �� Z
e �� Ze �� Ze �� Ze �� Ze �� Zdd� Zdd� Zd S )
� )�absolute_import�division�print_function)�
exceptions)�ffi�lib)�ensurec C s� t |�tkrt�d��t |�tkr,t�d��dt | }t�dt |��}t� ||t |�||�}t
|dkdtjd� 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 zEncryption failed�ZraisingN)�len�crypto_secretbox_KEYBYTES�exc�
ValueError�crypto_secretbox_NONCEBYTES�crypto_secretbox_ZEROBYTESr �newr �crypto_secretboxr �CryptoError�buffer�crypto_secretbox_BOXZEROBYTES)�message�nonce�key�padded�
ciphertext�res� r �@/usr/lib/python3/dist-packages/nacl/bindings/crypto_secretbox.pyr s
r c C s� t |�tkrt�d��t |�tkr,t�d��dt | }t�dt |��}t� ||t |�||�}t
|dkdtjd� t�|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 Z plaintextr r r r r! 8 s$
�
�r! N)Z
__future__r r r Znaclr r Znacl._sodiumr r Znacl.exceptionsr Zcrypto_secretbox_keybytesr Zcrypto_secretbox_noncebytesr Zcrypto_secretbox_zerobytesr Zcrypto_secretbox_boxzerobytesr Zcrypto_secretbox_macbytesZcrypto_secretbox_MACBYTESZ!crypto_secretbox_messagebytes_maxZ!crypto_secretbox_MESSAGEBYTES_MAXr r! r r r r �<module> s