WcIc s 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.NZwin32z,The crypt module is not supported on Windowsz;The required _crypt module was not built as part of CPython) SystemRandom) namedtuple)i )Zremovez./cseZdZdZdZdS)_MethodziClass representing a salt method per the Modular Crypt Format or the legacy 2-character crypt method.cs:dj|jS)Nz)Zformatname)Zselfs /usr/lib64/python3.12/crypt.py__repr__z_Method.__repr__ s"))$))44N)__name__Z __module__Z __qualname____doc__rrrrrs-((55555rrz name ident salt_chars total_sizeroundscs| 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 integerz$2i izrounds must be a power of 2iiz%rounds out of the range 2**4 to 2**31Z02d)56iiɚ;z+rounds out of the range 1000 to 999_999_999zrounds=z$ doesn't support the rounds argumentc3sPK|] }tjt"dSN)_srZchoice _saltchars)Z.0Zchar rz zmksalt..Fs+MMDJ'''''MMr) methods isinstanceZintZ TypeErrorZ __class__r ZidentZ bit_lengthZ ValueErrorZjoinZrangeZ salt_chars)methodr ZsZ log_roundss rmksaltr$s ~ *VS"9"96++445556 6 <<<      ||| Q3.. >JJq1Jj(( !>?? ((((b(( !HII) !HII ! ! ! !!  # #  60000[00 !NOO1 !NOO $6$$$ $AA  FHHHIIMME&:K:K4LMM MMA Hrcsv|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()``. )rrr_cryptcrypt)ZwordsaltrrrrJs/ |z$00d| <<d ##rcst|g|R}|td|z<t||}d} td|}|r4t||jkrtj|dSdS#t$rJ}|j t j t jt jhvrYd}~dSd}~wwxYw)NZMETHOD_r rFT) rZglobalsrrZOSErrorerrnoZEINVALZEPERMZENOSYSlenZ total_sizerZappend)rr ZargsrrZresultZes r _add_methodr\s T !D ! ! !F"(GIi$ & ( (D Fr4 v#f+!2!222vt 5  77u||U[[%,,? ? ?55555 sA88 C >CCC ZSHA512riijZSHA256ri?)ZbZyZarZBLOWFISHrii;ZMD5Z1ii"ZCRYPTirr)r ZsysZ_sysrZModuleNotFoundErrorZplatformZ ImportErrorrZstringZ_stringZwarningsZrandomrZ _SystemRandomZ collectionsrZ _namedtupleZ _deprecatedr Z ascii_lettersZdigitsrrrrrrrZ_vrr rrr sKKYMMM 000000111111Xg... " "W^^ 3d : mo55555kk)%GH55# $# # # # # L $ $ $ $ $(" Hc2s## Hc2r"" B{:sRxR##b'\$GGG E32 GT1b!! kYYY }}kHIIkWXX Ys C(D