
    !|g                     T    d dl mZ d dlZd dlmZ  e         G d d      Z e       Zy)    )FernetN)load_dotenvc                   2    e Zd Zd ZdedefdZdedefdZy)
Encryptionc                     t        j                  d      }|st        d      	 t        |j	                               | _        y # t        $ r}t        dt        |             d }~ww xY w)NENCRYPTION_KEYz1ENCRYPTION_KEY not found in environment variableszInvalid ENCRYPTION_KEY format: )osgetenv
ValueErrorr   encodefernet	Exceptionstr)selfencryption_keyes      0/var/www/html/fluten_python/common/encryption.py__init__zEncryption.__init__	   sd    #34PQQ	I !6!6!89DK 	I>s1vhGHH	Is   A 	A(A##A(textreturnc                 x    |s|S | j                   j                  |j                               j                         S )zEncrypt text)r   encryptr   decode)r   r   s     r   r   zEncryption.encrypt   s.    K{{""4;;=188::    encrypted_textc                 x    |s|S | j                   j                  |j                               j                         S )zDecrypt text)r   decryptr   r   )r   r   s     r   r   zEncryption.decrypt   s2    !!{{"">#8#8#:;BBDDr   N)__name__
__module____qualname__r   r   r   r    r   r   r   r      s1    	I;C ;C ;Ec Ec Er   r   )cryptography.fernetr   r	   dotenvr   r   
encryptionr!   r   r   <module>r%      s*    & 	  E E2 \
r   