o
0¦i ã @ s. d Z ddlZzddlZW n ey ejdkredƒ‚edƒ‚w 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„ 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 | j¡S )Nz)ÚformatÚname)Ú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_size©Úroundsc C sH | du rt d } |durt|tƒst|jj› d�ƒ‚| js d}nd| j› d�}| jrd| jd dkrd|du r8d}n#t |d ¡}|d|> krItd ƒ‚d
| krVdks[tdƒ‚ tdƒ‚||d
›d�7 }n/| jdv rˆ|dur‡d| krzdkstdƒ‚ tdƒ‚|d|› d�7 }n|dur“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 s € zmksalt..)ÚmethodsÚ
isinstanceÚintÚ TypeErrorÚ __class__r ZidentÚ
bit_lengthÚ
ValueErrorÚjoinÚrangeZ
salt_chars)Úmethodr ÚsZ
log_roundsr r r Úmksalt s<