OwlCyberSecurity - MANAGER
Edit File: crypto_secretbox.cpython-38.pyc
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