a
XC?h� � @ s6 d Z ddlZzddlZW n. eyF ejdkr:ed��ned��Y n0 ddlZddlZ ddl
mZ ddl
mZ e je j d Ze� ZG d d
� d
ed
d��Zd&dd�d
d�Zd'dd�Zg Zdd�dd�Zedddd� edddd� dD ](Zedde ddee� dd�r� �qq�edd d!d"� ed#dd$d%� [[dS )(zEWrapper to the POSIX crypt library call and associated functionality.� NZwin32z,The crypt module is not supported on Windowsz;The required _crypt module was not built as part of CPython)�SystemRandom)�
namedtuplez./c @ s e Zd ZdZdd� ZdS )�_MethodziClass representing a salt method per the Modular Crypt Format or the
legacy 2-character crypt method.c C s d� | j�S )Nz)�format�name)�self� r �*/opt/alt/python39/lib64/python3.9/crypt.py�__repr__ s z_Method.__repr__N)�__name__�
__module__�__qualname__�__doc__r
r r r r r s r z name ident salt_chars total_size��roundsc C sB | du rt d } |dur4t|t�s4t|jj� d���| js@d}nd| j� d�}| jr�| jd dkr�|du rpd}n@t�|d �}|d|> kr�td ��d
| kr�dks�n td��||d
�d�7 }n^| jdv �r|du�r d| kr�dks�n td��|d|� d�7 }n|du�r t| � d���|d� dd� t
| j�D ��7 }|S )zsGenerate a salt for the specified method.
If not specified, the strongest available method will be used.
Nr z+ object cannot be interpreted as an integer� �$�2� � zrounds must be a power of 2� � z%rounds out of the range 2**4 to 2**31Z02d)�5�6i� i�ɚ;z+rounds out of the range 1000 to 999_999_999zrounds=z$ doesn't support the rounds argumentc s s | ]}t �t�V qd S )N)�_srZchoice�
_saltchars)�.0�charr r r � B � zmksalt..)�methods�
isinstance�int� TypeError� __class__r Zident�
bit_length�
ValueError�join�rangeZ
salt_chars)�methodr �sZ
log_roundsr r r �mksalt s2
r+ c C s&