o
    Õl>j  ã                   @   s”   d dl Z d dlZd dlmZ zd dlmZ W n	 ey   Y nw d dlZeƒ jZedd„ ƒZ	G dd„ dej
jƒZG dd	„ d	eƒZG d
d„ deƒZdS )é    N)ÚExceptionTrap)Úkeyczarc                   C   s
   t j d S ©N)r   Ú__name__© r   r   úI/home/thesage/.local/lib/python3.10/site-packages/keyrings/alt/keyczar.pyÚhas_keyczar   s   
r   c                   @   sH   e Zd ZdZejdd„ ƒZejdd„ ƒZedd„ ƒZ	dd	„ Z
d
d„ ZdS )ÚBaseCrypterzmBase Keyczar keyset encryption and decryption.
    The keyset initialisation is deferred until required.
    c                 C   ó   dS )z9Location for the main keyset that may be encrypted or notNr   ©Úselfr   r   r   Úkeyset_location   s   zBaseCrypter.keyset_locationc                 C   r
   )zoLocation for the encrypting keyset.
        Use None to indicate that the main keyset is not encrypted
        Nr   r   r   r   r   Úencrypting_keyset_location!   s   z&BaseCrypter.encrypting_keyset_locationc                 C   sZ   t | dƒs*| jstdƒ‚tj | j¡}| jr$tj | j¡}tj 	||¡}t |¡| _
| j
S )zThe actual keyczar crypterÚ_crypterzNo encrypted keyset location!)Úhasattrr   Ú
ValueErrorr   ÚreadersÚCreateReaderr   ÚCrypterÚReadÚEncryptedReaderr   )r   ÚreaderÚencrypting_keyczarr   r   r   Úcrypter(   s   
ÿzBaseCrypter.crypterc                 C   ó   |sdS | j  |¡S )zEncrypt the value.Ú )r   ÚEncrypt©r   Úvaluer   r   r   Úencrypt8   ó   zBaseCrypter.encryptc                 C   r   )zDecrypt the value.r   )r   ÚDecryptr   r   r   r   Údecrypt>   r    zBaseCrypter.decryptN)r   Ú
__module__Ú__qualname__Ú__doc__ÚabcÚabstractpropertyr   r   Úpropertyr   r   r"   r   r   r   r   r	      s    


r	   c                   @   s2   e Zd ZdZd	dd„Zedd„ ƒZedd„ ƒZdS )
r   z>A Keyczar crypter using locations specified in the constructorNc                 C   s   || _ || _d S r   )Ú_keyset_locationÚ_encrypting_keyset_location)r   r   r   r   r   r   Ú__init__H   s   
zCrypter.__init__c                 C   ó   | j S r   )r)   r   r   r   r   r   L   ó   zCrypter.keyset_locationc                 C   r,   r   )r*   r   r   r   r   r   P   r-   z"Crypter.encrypting_keyset_locationr   )r   r#   r$   r%   r+   r(   r   r   r   r   r   r   r   E   s    

r   c                   @   s0   e Zd ZdZdZdZedd„ ƒZedd„ ƒZdS )	ÚEnvironCrypterz?A Keyczar crypter using locations specified by environment varsÚ"KEYRING_KEYCZAR_ENCRYPTED_LOCATIONÚ#KEYRING_KEYCZAR_ENCRYPTING_LOCATIONc                 C   s$   t j | j¡}|std| j ƒ‚|S )Nz%s environment value not set)ÚosÚenvironÚgetÚKEYSET_ENV_VARr   )r   Úvalr   r   r   r   [   s   zEnvironCrypter.keyset_locationc                 C   s   t j | j¡S r   )r1   r2   r3   ÚENC_KEYSET_ENV_VARr   r   r   r   r   b   s   z)EnvironCrypter.encrypting_keyset_locationN)	r   r#   r$   r%   r4   r6   r(   r   r   r   r   r   r   r.   U   s    
r.   )r&   r1   Újaraco.contextr   r   ÚImportErrorÚkeyring.backendÚkeyringÚpassesr   Úbackendr   r	   r.   r   r   r   r   Ú<module>   s    ÿ
.