B
    `5                 @   sT   d Z ddlZddlZddlmZ ddlmZmZmZ dd Z	dd Z
d	Zd
d ZdS )z-Encryption module that uses pyca/cryptography    N)default_backend)Cipher
algorithmsmodesc             C   sJ   t d}tt|t|t d }|	| |
  }||j | S )N   )backend)osurandomr   r   AESr   GCMr   	encryptorupdatefinalizetag)datakeyivr   
ciphertext r   g/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/beaker/crypto/pyca_cryptography.py
aesEncrypt   s    
r   c             C   sX   | d d }| dd }| dd  }t t|t||t d }|||  S )Nr      )r   )	r   r   r
   r   r   r   	decryptorr   r   )r   r   r   r   r   r   r   r   r   
aesDecrypt   s    
r   Tc               C   s   dS )N    r   r   r   r   r   getKeyLength3   s    r   )__doc__r   jsonZcryptography.hazmat.backendsr   Z&cryptography.hazmat.primitives.ciphersr   r   r   r   r   Zhas_aesr   r   r   r   r   <module>   s   