o 0¦iã@s.dZddlZzddlZWney ejdkredƒ‚edƒ‚wddlZddlZ ddl m Z ddl mZe je jdZe ƒZGd d „d ed d ƒƒZd&dd œd d„Zd&dd„ZgZdd œdd„ZeddddƒeddddƒdD]Zeddeddeeƒ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@seZdZdZdd„ZdS)Ú_MethodziClass representing a salt method per the Modular Crypt Format or the legacy 2-character crypt method.cCs 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 rrrr rs rz name ident salt_chars total_size©ÚroundscCsH|durtd}|durt|tƒst|jj›d�ƒ‚|js d}nd|j›d�}|jrd|jddkrd|dur8d}n#t |d¡}|d|>krItd ƒ‚d |krVd ks[td ƒ‚td ƒ‚||d ›d�7}n/|jdvrˆ|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. Nrz+ 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 argumentcss�|]}t t¡VqdS©N)Ú_srZchoiceÚ _saltchars)Ú.0Úcharrrr Ú Bs€zmksalt..) ÚmethodsÚ isinstanceÚintÚ TypeErrorÚ __class__r ZidentÚ bit_lengthÚ ValueErrorÚjoinÚrangeZ salt_chars)ÚmethodrÚsZ log_roundsrrr Úmksalt s< ÿ ÿ€r+cCs&|dus t|tƒr t|ƒ}t ||¡S)aRReturn a string representing the one-way hash of a password, with a salt prepended. If ``salt`` is not specified or is ``None``, the strongest available method will be selected and a salt generated. Otherwise, ``salt`` may be one of the ``crypt.METHOD_*`` values, or a string as returned by ``crypt.mksalt()``. N)r!rr+Ú_cryptÚcrypt)ZwordÚsaltrrr r-Fs  r-c Gs t|g|¢RŽ}|tƒd|<t||d�}d}ztd|ƒ}Wnty=}z|jtjtjtjhvr8WYd}~dS‚d}~ww|rNt |ƒ|j krNt   |¡dSdS)NZMETHOD_rrFT) rÚglobalsr+r-ÚOSErrorÚerrnoZEINVALZEPERMZENOSYSÚlenZ total_sizer Úappend)rrÚargsr)r.ÚresultÚerrr Ú _add_methodXs  €ü r7ZSHA512rééjZSHA256ré?)ÚbÚyÚarZBLOWFISHréé;ZMD5Ú1éé"ZCRYPTéé r)rÚsysÚ_sysr,ÚModuleNotFoundErrorÚplatformÚ ImportErrorr1ÚstringZ_stringZrandomrZ _SystemRandomÚ collectionsrZ _namedtupleZ ascii_lettersZdigitsrrrr+r-r r7Z_vr2rrrr Ús:   ü   &ÿ