U
    <æ{fI
  ã                   @   s|   d Z ddlZddlmZmZ ddlZddlZeeef eej	j
ejjf dœdd„Zeej	j
ef eeef dœdd	„ZdS )
zA place to store TSIG keys.é    N)ÚAnyÚDict)ÚtextringÚreturnc                 C   sb   i }|   ¡ D ]P\}}tj |¡}t|tƒr@tj ||¡j||< q|\}}tj |||¡||< q|S )a7  Convert a dictionary containing (textual DNS name, base64 secret)
    pairs into a binary keyring which has (dns.name.Name, bytes) pairs, or
    a dictionary containing (textual DNS name, (algorithm, base64 secret))
    pairs into a binary keyring which has (dns.name.Name, dns.tsig.Key) pairs.
    @rtype: dict)	ÚitemsÚdnsÚnameÚ	from_textÚ
isinstanceÚstrÚtsigÚKeyÚsecret)r   Úkeyringr   ÚvalueZknameÚ	algorithmr   © r   úN/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/dns/tsigkeyring.pyr	      s    
r	   )r   r   c                 C   sv   i }dd„ }|   ¡ D ]\\}}| ¡ }t|tƒr<||ƒ||< qt|jtƒrT||jƒ}n
t|jƒ}|j ¡ |f||< q|S )a;  Convert a dictionary containing (dns.name.Name, dns.tsig.Key) pairs
    into a text keyring which has (textual DNS name, (textual algorithm,
    base64 secret)) pairs, or a dictionary containing (dns.name.Name, bytes)
    pairs into a text keyring which has (textual DNS name, base64 secret) pairs.
    @rtype: dictc                 S   s   t  | ¡ ¡  ¡ S )N)Úbase64ÚencodebytesÚdecodeÚrstrip)r   r   r   r   Ú	b64encode6   s    zto_text.<locals>.b64encode)r   Úto_textr
   Úbytesr   r   r   )r   r   r   r   ÚkeyZtnameZtext_secretr   r   r   r   -   s    

r   )Ú__doc__r   Útypingr   r   Zdns.namer   Zdns.tsigr   r   ÚNamer   r   r	   r   r   r   r   r   Ú<module>   s   (