o
0i @ s. d Z ddlZzddlZW n ey ejdkrededw ddlZddlZ ddl
mZ ddl
mZ e je j d Ze ZG d d
d
ed
dZd&ddd
dZd&ddZg ZddddZedddd edddd dD ]Zedde ddee ddr nqqedd 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 | jS )Nz)formatname)self r ,/opt/alt/python310/lib64/python3.10/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_sizeroundsc C sH | du rt d } |durt|tst|jj d| js d}nd| j d}| jrd| jd dkrd|du r8d}n#t|d }|d|> krItd d
| krVdks[td td||d
d7 }n/| jdv r|durd| krzdkstd td|d| d7 }n|durt| 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 B s zmksalt..)methods
isinstanceint TypeError __class__r Zident
bit_length
ValueErrorjoinrangeZ
salt_chars)methodr sZ
log_roundsr r r mksalt s<