\dI dZddlZ ddlZn*#e$r"ejdkr ededwxYwddlZddlZ ddl Z ddl m Z ddlmZe jed e je jzd zZe ZGd d ed d Zd%dddZd%dZgZdddZeddddedddddD]#Zeddezddeezdrn$eddd d!ed"dd#d$[[dS)&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.c6d|jS)Nz)formatname)selfs ..\python\lib\crypt.py__repr__z_Method.__repr__ s"))$)444N)__name__ __module__ __qualname____doc__rrrr r s-((55555rr z name ident salt_chars total_sizeroundsc| td}|1t|tst|jjd|jsd}n d|jd}|jrs|jddkrb|d}nSt|dz }|d|zkrtd d |cxkrd ksntd ||d dz }nG|jdvr*|'d|cxkrdksntd|d|dz }n|t|d|d dt|j Dz }|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 argumentc3TK|]#}ttV$dSN)_srchoice _saltchars).0chars r zmksalt..Fs.MMDJ''MMMMMMr) methods isinstanceint TypeError __class__rident bit_length ValueErrorjoinrange salt_chars)methodrs log_roundss rmksaltr:$s ~ *VS"9"96+455566 6 <      |J Q3.. >JJq11Jj(( !>??? ((((b(((( !HIII ! ! ! !!  # #  60000[0000 !NOOO $6$$$ $A  FHHHIIIMME&:K4L4LMMM M MMA Hrcx|t|trt|}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=Js4 |z$00|d|| <d # ##rct|g|R}|td|z<t||}d} td|}nC#t$r6}|jt jt jt jhvrYd}~dSd}~wwxYw|r4t||j krt |dSdS)NMETHOD_rrFT) r globalsr:r=OSErrorerrnoEINVALEPERMENOSYSlen total_sizer,append)r rargsr7r?resultes r _add_methodrN\s T !D ! ! !F"(GIIi$ & ( ( (D Fr4  7u|U[%,? ? ?55555  #f++!222vt 5sA B*BBBSHA512r#jSHA256r"?)byarBLOWFISHr;MD51"CRYPTrr%)rsys_sysr<ModuleNotFoundErrorplatform ImportErrorrDstring_stringwarningsrandomr _SystemRandom collectionsr _namedtuple _deprecatedr ascii_lettersdigitsr(r&r r:r=r,rN_vrHrrrrps1KKYMMMMYYY }kHIIIkWXXX Y  000000111111Xg.... "W^ 3d : moo55555kk)%GHH555# $# # # # # L $ $ $ $ $(" Hc2s### Hc2r""" B{:sRxR##b''\$GGG  E32 GT1b!!! s '4