QfP`dZddlZddlZddlZgdZeefZdZd5dZ d6dZ dZ d Z ejd d Zejd d Zd Zd ZdZdZdZdZdZiaiadZd7dZdZej9de_d7dZej9dee_dZej9de_d8dZej9dde_dZ d8dZ!da"da#d Z$d!Z%d9d"Z&ddddd#d$Z'ddd%d&d'Z(d(Z)da*da+da,d8d)Z-d*Z.d+Z/e/d,zd-zZ0d.Z1d/Z2d0Z3d1Z4d2Z5d3Z6e7d4k(re6yy):zDBase16, Base32, Base64 (RFC 3548), Base85 and Ascii85 data encodingsN)encodedecode encodebytes decodebytes b64encode b64decode b32encode b32decode b32hexencode b32hexdecode b16encode b16decode b85encode b85decode a85encode a85decodestandard_b64encodestandard_b64decodeurlsafe_b64encodeurlsafe_b64decodec.t|tr |jdSt|t r|S t |jS#t$r t dwxYw#t$r$td|jjzdwxYw)Nasciiz4string argument should contain only ASCII charactersz>argument should be a bytes-like object or ASCII string, not %r) isinstancestrrUnicodeEncodeError ValueError bytes_types memoryviewtobytes TypeError __class____name__ss -/opt/alt/python312/lib64/python3.12/base64.py_bytes_from_decode_datar&"s!S U88G$ $![!K!}$$&& " UST T U K)+,;;+?+?@AFJ KKsAA'A$'-Bctj|d}|%|jtj d|S|S)a*Encode the bytes-like object s using Base64 and return a bytes object. Optional altchars should 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. F)newline+/)binascii b2a_base64 translatebytes maketrans)r$altcharsencodeds r%rr3s=!!!U3G  !ABB NFct|}|0t|}|jtj|d}t j ||S)aDecode the Base64 encoded bytes-like object or ASCII string s. Optional altchars must be a bytes-like object or ASCII string of length 2 which specifies the alternative alphabet used instead of the '+' and '/' characters. The result is returned as a bytes object. A binascii.Error is raised if s is incorrectly padded. If validate is False (the default), characters that are neither in the normal base-64 alphabet nor the alternative alphabet are discarded prior to the padding check. If validate is True, these non-alphabet characters in the input result in a binascii.Error. For more information about the strict base64 check, see: https://docs.python.org/3.11/library/binascii.html#binascii.a2b_base64 r)) strict_mode)r&r,r-r.r* a2b_base64)r$r/validates r%rrAsJ$ "A*84 KK%8 9   qh 77r1ct|S)zrEncode bytes-like object s using the standard Base64 alphabet. The result is returned as a bytes object. )rr#s r%rr[s Q<r1ct|S)aQDecode bytes encoded with the standard Base64 alphabet. Argument s is a bytes-like object or ASCII string to decode. The result is returned as a bytes object. A binascii.Error is raised if the input is incorrectly padded. Characters that are not in the standard alphabet are discarded prior to the padding check. )rr#s r%rrbs Q<r1r)s-_c>t|jtS)zEncode bytes using the URL- and filesystem-safe Base64 alphabet. Argument s is a bytes-like object to encode. The result is returned as a bytes object. The alphabet uses '-' instead of '+' and '_' instead of '/'. )rr,_urlsafe_encode_translationr#s r%rrps Q< ! !"= >>r1cXt|}|jt}t|S)aDecode bytes using the URL- and filesystem-safe Base64 alphabet. Argument s is a bytes-like object or ASCII string to decode. The result is returned as a bytes object. A binascii.Error is raised if the input is incorrectly padded. Characters that are not in the URL-safe base-64 alphabet, and are not a plus '+' or slash '/', are discarded prior to the padding check. The alphabet uses '-' instead of '+' and '_' instead of '/'. )r&r,_urlsafe_decode_translationrr#s r%rrys' "A /0A Q<r1zK Encode the bytes-like objects using {encoding} and return a bytes object. a Decode the {encoding} encoded bytes-like object or ASCII string s. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. {extra_args} The result is returned as a bytes object. A binascii.Error is raised if the input is incorrectly padded or if there are non-alphabet characters present in the input. a RFC 3548 allows for optional mapping of the digit 0 (zero) to the letter O (oh), and for optional mapping of the digit 1 (one) to either the letter I (eye) or letter L (el). The optional argument map01 when not None, specifies which letter the digit 1 should be mapped to (when map01 is not None, the digit 0 is always mapped to the letter O). For security purposes the default is None, so that 0 and 1 are not allowed in the input. s ABCDEFGHIJKLMNOPQRSTUVWXYZ234567s 0123456789ABCDEFGHIJKLMNOPQRSTUVc|tvr>|Dcgc]}t|f}}|Dcgc]}|D]}||z c}}t|<d}t|tst |j }t |dz}|r |dd|z zz}t}tj}t|} tdt |dD]<}||||dz} || | dz | | dz dzz| | dz dzz| | dzzz }>|dk(rd |d dt|S|d k(rd |d dt|S|dk(rd|ddt|S|dk(rd|ddt|Scc}wcc}}w)Nri s======is====s====) _b32tab2r-rrrrlen bytearrayint from_bytesrange) alphabetr$ib32tabableftoverr0rNb32tab2cs r% _b32encoderXsx'/0x!%+x0-3DVVa!eVeVD a % qM ! ! #1vzH X& &kGJx G 1c!fa  qAE{ #GAG$Q"W-./Q"W-./AI&' !1}   > Q > Q  > Q >;1Ds EEc`|tvr&t|Dcic]\}}|| c}}t|<t|}t|dzrt j d|3t|}|j tjdd|z}|r|j}t|}|jd}|t|z }t}t|} tdt|dD]4} || | dz} d} | D] } | dz| | z}  || jdz }6|dzs|d vrt j d|r.|r, d|zz} | jd}d d|zz dz}|d||d dt|Scc}}w#t$rt j ddwxYw) NzIncorrect paddings01OrHrr=zNon-base32 digit found>rrBrErG+)_b32rev enumerater&rKr*Errorr,r-r.upperrstriprLrOKeyErrorto_bytes)rPr$casefoldmap01kvlpadcharsdecodedb32revrQquantaaccrWlastrUs r% _b32decoderqsw.7.AB.AdaQT.AB"A 1vznn011 '. KKte|< = GGI AA A3q6zHkG X F 1c!fa 1a!e Eax6!9, 3<<?"! 1u/nn011G H ||AX%!+IX >OC8 E..!9: D Es FF  F-c"tt|SN)rX _b32alphabetr#s r%r r s lA &&r1base32)encodingc&tt|||Srs)rqrt)r$rfrgs r%r r s lAx 77r1)rv extra_argsc"tt|Srs)rX_b32hexalphabetr#s r%r r s oq ))r1 base32hexc$tt||Srs)rqrzr$rfs r%r r s oq( 33r1cHtj|jS)zKEncode the bytes-like object s using Base16 and return a bytes object. )r*hexlifyrbr#s r%r r s   A  $ $ &&r1ct|}|r|j}tjd|rt j dt j |S)aDecode the Base16 encoded bytes-like object or ASCII string s. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. The result is returned as a bytes object. A binascii.Error is raised if s is incorrectly padded or if there are non-alphabet characters present in the input. s [^0-9A-F]zNon-base16 digit found)r&rbresearchr*ra unhexlifyr}s r%rrsK "A GGI yyq!nn566   a  r1s<~s~>ct|tst|j}t | dz}|r|d|zz}t j dt |dzzj|}|Dcgc].}|r|sdn%|r|dk(rdn||dz||dzd zz||dzz0} }|r!|s| d dk(r |d d z| d <| d d| | d <d j| Scc}w)NrGr>z!%dIzi yi^ Ui9rIrr=r1) rrrrrKstructStructunpackjoin) rTcharschars2padfoldnuls foldspacespaddingwordswordchunkss r% _85encoder0s  a % qM ! ! #Aw!mG   MM&CFaK0 1 8 8 ;E !  $ td TZ%7ddfn%dbj4'()TBY !   !s ": qAF2JBZ '*r 88F !s:3C#)rwrapcolradobectHtddDcgc]}t|fc}atDcgc]}tD]}||z c}}at tt|d|}|r t |z}|rqt |rdnd|}tdt||Dcgc] }||||z }}|r%t|ddz|kDr|jdd j|}|r |tz }|Scc}wcc}}wcc}w) aEncode bytes-like object b using Ascii85 and return a bytes object. 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 (b'\n') characters added to it. If this is non-zero, each output line will be at most this many characters long, excluding the trailing newline. pad controls whether the input 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. !vTrCrBrrIr1 ) _a85chars2rOr- _a85charsr _A85STARTmaxrKappendr_A85END) rTrrrrrQrSresultrs r%rrHs(*/C.9.QUA4[.9 '0Dy!)Qq1u)uyD q)ZdJ GF V#5aa1 CK9;9aAK(9 ; 6":"W, c"F# ' M%:D;sC2C7C=s )rr ignorecharsc0t|}|rS|jtstdj t|j t r|dd}n|dd}tjdj}g}|j}g}|j}|j} |dzD]} d| cxkrdkrEnnB|| t|d k(s(d } |D] } d | z| dz z}  ||| | S| d k(r|r td|dn|r| dk(r|r td|d| |vrtd| zdj|} dt|z } | r| d| } | S#tj$r td dwxYw)aDecode the Ascii85 encoded bytes-like object or ASCII string b. 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. The result is returned as a bytes object. z1Ascii85 encoded byte sequences must end with {!r}rCN!Isuuuurur=rrzAscii85 overflowzzz inside Ascii85 5-tuplesyzy inside Ascii85 5-tuples zNon-Ascii85 digit found: %cr1rG)r&endswithrrformat startswithrrrpackrclearrKerrorr)rTrrrpackIrldecoded_appendcurr curr_append curr_clearxrorrs r%rrqs "A zz'""F7O  << "!BA#2A MM$  $ $EG^^N D++KJ \ a "7 " N4yA~As(a"f-CC"5:. '\ !;<< ; ' AL !;<< . / +  :Q>? ?14XXg F#d)mG '" M-||C$%78dBCs *E55 FsU0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~ctBtDcgc]}t|fc}atDcgc]}tD]}||z c}}at tt|Scc}wcc}}w)zEncode bytes-like object b in base85 format and return a bytes object. If pad is true, the input is padded with b'\0' so its length is a multiple of 4 bytes before encoding. ) _b85chars2 _b85alphabetr- _b85charsr)rTrrQrSs r%rrs]*67,QUA4[,7 '0Dy!)Qq1u)uyD Q :s 338Ds AA$ct&dgdzattD]\}}|t|<t|}t | dz}|d|zz}g}t j dj}tdt |dD]<}|||dz}d} |D]}|dzt|z} |j||>d j|} |r| d| } | S#t$r0t|D] \}}t|td||zzdwxYw#t j$rtd |zdwxYw) zqDecode the base85-encoded bytes-like object or ASCII string b The result is returned as a bytes object. Nr=~rrrz#bad base85 character at position %dz+base85 overflow in hunk starting at byte %dr1)_b85decr`rr&rKrrrrOr rrrr) rTrQrWroutrchunkrojrs r%rrsy&3,l+DAqGAJ, "AAw!mG D7NA C MM$  $ $E 1c!fa !AE  Bh+ , JJuSz "!$XXc]F '" M !%(11:%$%J'(1u&./489)   || ,J !"'+ , ,sC ,D #DD#D?LrGrEc|jtx}rt|tkr^|jtt|z x}r;||z }t|tkr$|jtt|z x}r;tj|}|j ||jtx}ryy)z1Encode a file; input and output are binary files.N)read MAXBINSIZErKr*r+write)inputoutputr$nslines r%rrszz*% %! %!fz!UZZ 3q68I-J'Jr'J GA!fz!UZZ 3q68I-J'Jr'J""1% T zz*% %! %r1c|jx}r:tj|}|j||jx}r9yy)z1Decode a file; input and output are binary files.N)readliner*r4r)rrrr$s r%rrsC.." "$ "    % Q.." "$ "r1c t|}|jdvr1d|jd|jj}t||j dk7r0d|j |jjfz}t|y#t$r*}d|jjz}t||d}~wwxYw)Nz"expected bytes-like object, not %s)rWrTBz#expected single byte elements, not z from rBz(expected 1-D data, not %d-D data from %s)rr r!r"rndim)r$merrmsgs r%_input_type_checkr s& qM xx&+,88Q[[5I5IKnvv{9+,661;;3G3G*HIn &2Q[[5I5IIn#%&s B B?%B::B?ct|g}tdt|tD]2}|||tz}|j t j |4dj|S)zVEncode a bytestring into a bytes object containing multiple lines of base-64 data.rr1)rrOrKrrr*r+r)r$piecesrQrs r%rrs`a F 1c!fj )!a*n% h))%01* 88F r1cBt|tj|S)z8Decode a bytestring of base-64 data into a bytes object.)rr*r4r#s r%rr'sa   q !!r1cddl}ddl}d|jdd} |j|jddd\}}t}D]8\}}|dk(rt}|d k(rt}|d k(rt}|d k(s-t |yr>|dd k7r6t|dd 5} || |j jdddy||jj|j jy#|j$rC}|j|_t |t ||jdYd}~d}~wwxYw#1swYyxYw)zSmall main programrNzusage: zx [-h|-d|-e|-u] [file|-] -h: print this help message and exit -d, -u: decode -e: encode (default)rBhdeurCz-ez-dz-uz-h-rb) sysgetoptargvrstderrstdoutprintexitrropenbufferstdin) rrusageoptsargsrfuncorSfs r%mainr.s( }% E]]388AB<8 d D1 9Vd 9Vd 9Vd 9eElF   Q3 $q'4 A CJJ%% &!  SYY  szz001 <<ZZ  c  e   ! s#"C4E 4E8EE E__main__rs)NF)FN)F)FFF)8__doc__rrr*__all__r-rLrr&rrrrr.r9r;rr_B32_ENCODE_DOCSTRING_B32_DECODE_DOCSTRING_B32_DECODE_MAP01_DOCSTRINGrtrzrJr_rXrqr rr r r r rrrrrrrrrrrrrr MAXLINESIZErrrrrrrr"r1r%rsK   $i  K" 84$ooeU;#ooeU;? $ 3 5  "H,^')00(0C 8)00(3N1P *,33[3I 4-33[?A4C ' !*    0 %aU%'R %E|DPE    4'Z 1na    "26 zFr1