Repository URL to install this package:
| 
      
     
      
        
        
        Version: 
        
         
  
        
    
          
          3.4.52  ▾
        
         
  
      
        
      
  
      
  
     | 
ó
ۍEYc           @` s   d  d l  m Z m Z m Z d  d l m Z d  d l m Z m	 Z	 d  d l
 m Z e	 j   Z
 e	 j   Z e	 j   Z e	 j   Z d   Z d   Z d S(   i    (   t   absolute_importt   divisiont   print_function(   t
   exceptions(   t   ffit   lib(   t   ensurec         C` sË   t  |  t k r$ t j d   n  t  |  t k rH t j d   n  d t |  } t j d t  |   } t j	 | | t  |  | |  } t
 | d k d d t j t j | t  |   } | t
 S(   sÆ   
    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
    s   Invalid keys
   Invalid noncet    s   unsigned char[]i    s   Encryption failedt   raising(   t   lent   crypto_secretbox_KEYBYTESt   exct
   ValueErrort   crypto_secretbox_NONCEBYTESt   crypto_secretbox_ZEROBYTESR   t   newR   t   crypto_secretboxR   t   CryptoErrort   buffert   crypto_secretbox_BOXZEROBYTES(   t   messaget   noncet   keyt   paddedt
   ciphertextt   res(    (    sS   /home/tvault/.virtenv/lib/python2.7/site-packages/nacl/bindings/crypto_secretbox.pyR      s    
!c         C` sË   t  |  t k r$ t j d   n  t  |  t k rH t j d   n  d t |  } t j d t  |   } t j	 | | t  |  | |  } t
 | d k d d t j t j | t  |   } | t
 S(   sÕ   
    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
    s   Invalid keys
   Invalid nonceR   s   unsigned char[]i    s1   Decryption failed. Ciphertext failed verificationR   (   R	   R
   R   R   R
   R   R   R   R   t   crypto_secretbox_openR   R   R   R   (   R   R   R   R   t	   plaintextR   (    (    sS   /home/tvault/.virtenv/lib/python2.7/site-packages/nacl/bindings/crypto_secretbox.pyR   6   s    
N(   t
   __future__R    R   R   t   naclR   R   t   nacl._sodiumR   R   t   nacl.exceptionsR   t   crypto_secretbox_keybytesR
   t   crypto_secretbox_noncebytesR
   t   crypto_secretbox_zerobytesR   t   crypto_secretbox_boxzerobytesR   R   R   (    (    (    sS   /home/tvault/.virtenv/lib/python2.7/site-packages/nacl/bindings/crypto_secretbox.pyt   <module>   s