WcI dZddlZ ddlZddlZddlZ ddl Z ddl m Z ddlmZe j"ed e j&e j(zd zZe ZGd d ed d Zd%dddZd%dZgZdddZeddddedddddD]Zeddezddeezdseddd d!ed"dd#d$[[dS#e$r#ej dkr ededwxYw)&zEWrapper to the POSIX crypt library call and associated functionality.Nwin32z,The crypt module is not supported on Windowsz;The required _crypt module was not built as part of CPython) SystemRandom) namedtuple) )removez./ceZdZdZdZdS)_MethodziClass representing a salt method per the Modular Crypt Format or the legacy 2-character crypt method.c:dj|jS)Nz)formatname)selfs /usr/lib64/python3.12/crypt.py__repr__z_Method.__repr__ s"))$))44N)__name__ __module__ __qualname____doc__rrrr r s-((55555rr z name ident salt_chars total_sizeroundsc| td}|7t|ts$t|jj d|j sd}nd|j d}|j r}|j ddkrg|d}nXtj|dz }|d|zkr td d |cxkrd kstd td ||d dz }nT|j dvr4|Dd|cxkrdkstdtd|d|dz }n|t|d|djdt|jDz }|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 2z%rounds out of the range 2**4 to 2**3102d)56iiɚ;z+rounds out of the range 1000 to 999_999_999zrounds=z$ doesn't support the rounds argumentc3PK|] }tjt"dSN)_srchoice _saltchars).0chars r zmksalt..Fs+MMDJ'''''MMr) methods isinstanceint TypeError __class__rident bit_length ValueErrorjoinrange salt_chars)methodrs log_roundss rmksaltr:$s ~ *VS"9"96++445556 6 <<<      ||| Q3.. >JJq1Jj(( !>?? ((((b(( !HII) !HII ! ! ! !!  # #  60000[00 !NOO1 !NOO $6$$$ $AA  FHHHIIMME&:K:K4LMM MMA Hrcv|t|tr t|}tj||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()``. )r-r r:_cryptcrypt)wordsalts rr=r=Js/ |z$00d| <<d ##rct|g|R}|td|z<t||}d} td|}|r4t||jkrtj|dSdS#t$rJ}|j t j t jt jhvrYd}~dSd}~wwxYw)NMETHOD_rrFT) r globalsr:r=OSErrorerrnoEINVALEPERMENOSYSlen total_sizer,append)r rargsr7r?resultes r _add_methodrN\s T !D ! ! !F"(GIi$ & ( (D Fr4 v#f+!2!222vt 5  77u||U[[%,,? ? ?55555 sA88 C >CCC SHA512r#jSHA256r"?)byarBLOWFISHr;MD51"CRYPTrr%)rsys_sysr<ModuleNotFoundErrorplatform ImportErrorrDstring_stringwarningsrandomr _SystemRandom collectionsr _namedtuple _deprecatedr ascii_lettersdigitsr(r&r r:r=r,rN_vrHrrrrpsKKYMMM 000000111111Xg... " "W^^ 3d : mo55555kk)%GH55# $# # # # # L $ $ $ $ $(" Hc2s## Hc2r"" B{:sRxR##b'\$GGG E32 GT1b!! kYYY }}kHIIkWXX Ys C(D