grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026î ¡ fÔNã@szdZddlZddlZddlZddddddd d d d d dddddddgZeefZdd„Zddd„Z dddd„Z dd„Z dd„Z ej ddƒZej ddƒZdd„Zdd„Zd Zdadad!d „Zddd"d „Zd#d „Zdd$d „Zdadad%Zd&Zdddd'd(„Zd)dd*dd+dd,dd-d„Zd)dd,dd.d/d0d„Zd1Z da!da"da#dd2d „Z$d3d„Z%d4Z&e&d5d6Z'd7d„Z(d8d„Z)d9d:„Z*d;d„Z+d<d=„Z,d>d„Z-d?d@„Z.dAdB„Z/dCdD„Z0e1dEkrve/ƒndS)FzDBase16, Base32, Base64 (RFC 3548), Base85 and Ascii85 data encodingséNÚencodeÚdecodeÚ encodebytesÚ decodebytesÚ b64encodeÚ b64decodeÚ b32encodeÚ b32decodeÚ b16encodeÚ b16decodeÚ b85encodeÚ b85decodeÚ a85encodeÚ a85decodeÚstandard_b64encodeÚstandard_b64decodeÚurlsafe_b64encodeÚurlsafe_b64decodecCs�t|tƒrDy|jdƒSWqDtk r@tdƒ‚YqDXnt|tƒrW|Syt|ƒjƒSWn+tk r˜td|j j ƒd‚YnXdS)NÚasciiz4string argument should contain only ASCII charactersz>argument should be a bytes-like object or ASCII string, not %r) Ú isinstanceÚstrrÚUnicodeEncodeErrorÚ ValueErrorÚ bytes_typesÚ memoryviewÚtobytesÚ TypeErrorÚ __class__Ú__name__)Ús©r ú+/opt/alt/python34/lib64/python3.4/base64.pyÚ_bytes_from_decode_data"s  r"cCsBtj|ƒdd…}|dk r>|jtjd|ƒƒS|S)aSEncode a byte string using Base64. s is the byte string to encode. Optional altchars must be a byte string of length 2 which specifies an alternative alphabet for the '+' and '/' characters. This allows an application to e.g. generate url or filesystem safe Base64 strings. The encoded byte string is returned. Nés+/éÿÿÿÿ)ÚbinasciiÚ b2a_base64Ú translateÚbytesÚ maketrans)rÚaltcharsÚencodedr r r!r3s  FcCszt|ƒ}|dk rBt|ƒ}|jtj|dƒƒ}n|rmtjd|ƒ rmtjdƒ‚ntj|ƒS)aDecode a Base64 encoded byte string. s is the byte string to decode. Optional altchars must be a string of length 2 which specifies the alternative alphabet used instead of the '+' and '/' characters. The decoded string is returned. A binascii.Error is raised if s is incorrectly padded. If validate is False (the default), non-base64-alphabet characters are discarded prior to the padding check. If validate is True, non-base64-alphabet characters in the input result in a binascii.Error. Ns+/s^[A-Za-z0-9+/]*={0,2}$zNon-base64 digit found) r"r'r(r)ÚreÚmatchr%ÚErrorÚ a2b_base64)rr*Zvalidater r r!rEs   cCs t|ƒS)zˆEncode a byte string using the standard Base64 alphabet. s is the byte string to encode. The encoded byte string is returned. )r)rr r r!r]scCs t|ƒS)aDecode a byte string encoded with the standard Base64 alphabet. s is the byte string to decode. The decoded byte string is returned. binascii.Error is raised if the input is incorrectly padded or if there are non-alphabet characters present in the input. )r)rr r r!rdss+/s-_cCst|ƒjtƒS)zÌEncode a byte string using a url-safe Base64 alphabet. s is the byte string to encode. The encoded byte string is returned. The alphabet uses '-' instead of '+' and '_' instead of '/'. )rr'Ú_urlsafe_encode_translation)rr r r!rrscCs%t|ƒ}|jtƒ}t|ƒS)aXDecode a byte string encoded with the standard Base64 alphabet. s is the byte string to decode. The decoded byte string is returned. binascii.Error is raised if the input is incorrectly padded or if there are non-alphabet characters present in the input. The alphabet uses '-' instead of '+' and '_' instead of '/'. )r"r'Ú_urlsafe_decode_translationr)rr r r!r{s s ABCDEFGHIJKLMNOPQRSTUVWXYZ234567cs®tdkrAdd„tDƒ‰‡fdd†ˆDƒad‰nt|tƒset|ƒjƒ}nt|ƒd}|r’|td|ƒ}ntƒ}t j }t}x{t dt|ƒdƒD]a}||||d…dƒ}|||d?||d ?d @||d ?d @||d @7}qÃW|d krGd |dd…|dkr…d|dd…™s zb32encode..cs'g|]}ˆD]}||‘qqSr r )r2ÚaÚb)Úb32tabr r!r4šs érÚbigééiÿé r#s======éés====éés===ó=iúÿÿÿéüÿÿÿéýÿÿÿr$) Ú_b32tab2Ú _b32alphabetrrrrÚlenr(Ú bytearrayÚintÚ from_bytesÚrange)rZleftoverr+rIZb32tab2r3Úcr )r7r!r�s4    +    c Csftdkr(dd„ttƒDƒant|ƒ}t|ƒdrVtjdƒ‚n|dk r�t|ƒ}|jtj dd|ƒƒ}n|r¥|j ƒ}nt|ƒ}|j dƒ}|t|ƒ}t ƒ}t}xžt d t|ƒdƒD]„}|||d…}d } y'x |D]} | d >|| } q"WWn$tk retjd ƒd‚YnX|| jd d ƒ7}qøW|r\| d |K} | jd d ƒ} |d krÏ| dd…|dd…Ïs zb32decode..ézIncorrect paddings01óOrArr8zNon-base32 digit foundr9r#r@r>r?r=r$éûÿÿÿéþÿÿÿrQrCrQrBrQ)Ú_b32revÚ enumeraterEr"rFr%r.r'r(r)ÚupperÚrstriprGrJÚKeyErrorÚto_bytes) rÚcasefoldZmap01ÚlZpadcharsÚdecodedZb32revr3ZquantaÚaccrKÚlastr r r!r ¸sJ    "        cCstj|ƒjƒS)zrEncode a byte string using Base16. s is the byte string to encode. The encoded byte string is returned. )r%ZhexlifyrU)rr r r!r scCsRt|ƒ}|r!|jƒ}ntjd|ƒrEtjdƒ‚ntj|ƒS)aˆDecode a Base16 encoded byte string. s is the byte string to decode. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. The decoded byte string is returned. binascii.Error is raised if s were incorrectly padded or if there are non-alphabet characters present in the string. s [^0-9A-F]zNon-base16 digit found)r"rUr,Úsearchr%r.Z unhexlify)rrYr r r!r s s<~s~>c sït|tƒs$t|ƒjƒ}nt|ƒ d}|rL|d|}ntjdt|ƒdƒj|ƒ}‡‡‡‡fdd†|Dƒ}|râ| râ|d dkrƈdd |d .r#r_rr8ór$r$r$r$) rrrrrFÚstructÚStructZunpackÚjoin) r6rbrcÚpadrdreÚpaddingZwordsÚchunksr )rbrcrdrer!Ú _85encode&s&  rmreÚwrapcolrjÚadobecstdkr>dd„tddƒDƒadd„tDƒant|tt|d|ƒ‰|rltˆ‰nˆrt|r�dnd ˆƒ‰‡‡fd d†td tˆƒˆƒDƒ}|rît|dƒdˆkrî|jd ƒqînd j|ƒ‰n|rˆt 7‰nˆS)a Encode a byte string using Ascii85. b is the byte string to encode. The encoded byte string is returned. foldspaces is an optional flag that uses the special short sequence 'y' instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This feature is not supported by the "standard" Adobe encoding. wrapcol controls whether the output should have newline ('\n') characters added to it. If this is non-zero, each output line will be at most this many characters long. pad controls whether the input string is padded to a multiple of 4 before encoding. Note that the btoa implementation always pads. adobe controls whether the encoded byte sequence is framed with <~ and ~>, which is used by the Adobe implementation. NcSsg|]}t|fƒ‘qSr )r()r2r3r r r!r4Us za85encode..é!évcSs'g|]}tD]}||‘qqSr )Ú _a85chars)r2r5r6r r r!r4Vs Tr>r#cs$g|]}ˆ||ˆ…‘qSr r )r2r3)Úresultrnr r!r4^s rrfs r$) rrrJÚ _a85chars2rmÚ _A85STARTÚmaxrFÚappendriÚ_A85END)r6rernrjrorlr )rsrnr!r>s"   Ú ignorecharss c Cst|ƒ}|r^|jtƒo-|jtƒsKtdjttƒƒ‚n|dd…}ntjdƒj }g}|j }g}|j }|j } x?|dD]3} d| ko¿dknrQ|| ƒt |ƒdkrÕd} x |D]} d | | d } qíWy||| ƒƒWn$tj k rCtd ƒd ‚YnX| ƒqÕq¢| dkr|rrtdƒ‚n|dƒq¢|r³| dkr³|r¦tdƒ‚n|dƒq¢| |krÅq¢q¢td| ƒ‚q¢Wdj|ƒ} dt |ƒ} | r| d | …} n| S)acDecode an Ascii85 encoded byte string. s is the byte string to decode. foldspaces is a flag that specifies whether the 'y' short sequence should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This feature is not supported by the "standard" Adobe encoding. adobe controls whether the input sequence is in Adobe Ascii85 format (i.e. is framed with <~ and ~>). ignorechars should be a byte string containing characters to ignore from the input. This should only contain whitespace characters, and by default contains all whitespace characters in ASCII. zAAscii85 encoded byte sequences must be bracketed by {!r} and {!r}r>z!Ióur?ó!rr8rarpzAscii85 overflowNr_zz inside Ascii85 5-tuplesr`zy inside Ascii85 5-tuples zNon-Ascii85 digit found: %crfrRsuuuurpéuézéy)r"Ú startswithruÚendswithrxrÚformatrgrhÚpackrwÚclearrFÚerrorri)r6reroryÚpackIr[Zdecoded_appendÚcurrZ curr_appendZ curr_clearÚxr\rsrkr r r!risP            sU0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~cCsHtdkr5dd„tDƒadd„tDƒant|tt|ƒS)z­Encode an ASCII-encoded byte array in base85 format. If pad is true, the input is padded with "\0" so its length is a multiple of 4 characters before encoding. NcSsg|]}t|fƒ‘qSr )r()r2r3r r r!r4¼s zb85encode..cSs'g|]}tD]}||‘qqSr )Ú _b85chars)r2r5r6r r r!r4½s )rˆÚ _b85alphabetÚ _b85chars2rm)r6rjr r r!r ²s c Cs¸tdkrCdgdax'ttƒD]\}}|t|)ÚwarningsÚwarnÚDeprecationWarningr)rr¡r r r!Ú encodestrings   r¤cCst|ƒtj|ƒS)z6Decode a bytestring of base-64 data into a bytestring.)rŸr%r/)rr r r!r's cCs)ddl}|jdtdƒt|ƒS)zLegacy alias of decodebytes().rNz7decodestring() is a deprecated alias, use decodebytes()r>)r¡r¢r£r)rr¡r r r!Ú decodestring,s   r¥c Cs|ddl}ddl}y)|j|jdd…dƒ\}}Wn`|jk r£}z=|j|_t|ƒtd|jdƒ|jdƒWYdd}~XnXt}xj|D]b\}}|dkrÒt}n|dkrçt }n|d krüt }n|d kr±t ƒdSq±W|r_|dd kr_t |dd ƒ�}|||jj ƒWdQXn||j j |jj ƒdS) zSmall main programrNr#Zdeutz�usage: %s [-d|-e|-u|-t] [file|-] -d, -u: decode -e: encode (default) -t: encode and decode string 'Aladdin:open sesame'r>z-ez-dz-uz-tú-Úrb)ÚsysÚgetoptÚargvr„ÚstderrÚstdoutÚprintÚexitrrÚtestÚopenÚbufferÚstdin) r¨r©ZoptsÚargsržÚfuncÚor5Úfr r r!Úmain5s0)       r·cCsRd}tt|ƒƒt|ƒ}tt|ƒƒt|ƒ}tt|ƒƒdS)NsAladdin:open sesame)r­Úreprrr)Zs0Ús1Ús2r r r!r¯Os  r¯Ú__main__)2Ú__doc__r,rgr%Ú__all__r(rGrr"rrrrr)r0r1rrrErDrSrr r r rrrtrurxrmrrr‰rˆrŠr�r r Z MAXLINESIZEr“rrrŸrr¤rr¥r·r¯rr r r r!Úsh             (K $+C *