o
    hI
                     @   s   d Z ddlZddlmZmZ ddlZddlZdeeef deej	j
ejjf fddZdeej	j
ef deeef fd	d
ZdS )zA place to store TSIG keys.    N)AnyDicttextringreturnc                 C   sb   i }|   D ](\}}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   valuekname	algorithmr    r   B/var/www/html/venv/lib/python3.10/site-packages/dns/tsigkeyring.pyr	      s   
r	   r   c                 C   sv   i }dd }|   D ].\}}| }t|tr||||< q
t|jtr*||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   keytnametext_secretr   r   r   r   -   s   

r   )__doc__r   typingr   r   dns.namer   dns.tsigr   r   Namer   r   r	   r   r   r   r   r   <module>   s   **