B
&<K;)N @ s d Z ddlZddlZddlmZ ddlmZ ej
ej d Ze Z
G dd de ddZd#dd d
dZd$dd
Zg Zdd ddZedddd edddd x,dD ]$Zedde ddee dd rP qW edddd ed dd!d" [[dS )%zEWrapper to the POSIX crypt library call and associated functionality. N)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 | jS )Nz)formatname)self r */opt/alt/python37/lib64/python3.7/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 | dkrt d } |dk r4t|ts4t|jj d| js@d}nd| j d}| jr| jd dkr|dkrpd}n@t|d }|d|> krtd d
| krdksn td||d
d7 }n^| jdkr|dk r d| krdksn td|d| d7 }n|dk r t| d|d dd t
| jD 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)56i iɚ;z+rounds out of the range 1000 to 999_999_999zrounds=z$ doesn't support the rounds argumentc s s | ]}t tV qd S )N)_srZchoice
_saltchars).0charr r r 8 s zmksalt..)methods
isinstanceint TypeError __class__r Zident
bit_length
ValueErrorjoinrangeZ
salt_chars)methodr sZ
log_roundsr r r mksalt s2
r) c C s&