QfP^ ddlZddlZddlZgdZeefZdZd4dZd5dZ dZ dZ ejd d Z ejd d Zd Zd Zd ZdZdZdZdZiaiadZd6dZdZej7de_d6dZej7dee_dZej7de_d7dZej7dde_dZ d7dZ!da"da#dZ$d Z%d8d!Z&ddddd"d#Z'ddd$d%d&Z(d'Z)da*da+da,d7d(Z-d)Z.d*Z/e/d+zd,zZ0d-Z1d.Z2d/Z3d0Z4d1Z5d2Z6e7d3k(re6yy)9N)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$'-Bc tj|d}|%|jtj d|S|S)NF)newline+/)binascii b2a_base64 translatebytes maketrans)r$altcharsencodeds r%rr3sB !!!U3G  !ABB NFc t|}|0t|}|jtj|d}t j ||S)Nr)) strict_mode)r&r,r-r.r* a2b_base64)r$r/validates r%rrAsO" "A*84 KK%8 9   qh 77r1c t|SN)rr#s r%rr[s Q<r1c t|Sr7)rr#s r%rrbs Q<r1r)s-_c@ t|jtSr7)rr,_urlsafe_encode_translationr#s r%rrps Q< ! !"= >>r1cZ t|}|jt}t|Sr7)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$ib32tabableftoverr0rOb32tab2cs r% _b32encoderYsx'/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 paddings01OrIrr>zNon-base32 digit found>rrCrFrH+)_b32rev enumerater&rLr*Errorr,r-r.upperrstriprMrPKeyErrorto_bytes)rQr$casefoldmap01kvlpadcharsdecodedb32revrRquantaaccrXlastrVs r% _b32decoderrsw.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|Sr7)rY _b32alphabetr#s r%r r s lA &&r1base32)encodingc&tt|||Sr7)rrrt)r$rgrhs r%r r s lAx 77r1)rv extra_argsc"tt|Sr7)rY_b32hexalphabetr#s r%r r s oq ))r1 base32hexc$tt||Sr7)rrrzr$rgs r%r r s oq( 33r1cJ tj|jSr7)r*hexlifyrcr#s r%r r s!   A  $ $ &&r1c t|}|r|j}tjd|rt j dt j |S)Ns [^0-9A-F]zNon-base16 digit found)r&rcresearchr*rb unhexlifyr}s r%rrsP "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)NrHr?z!%dIzi yi^ Ui9rJrr>r1) rrrrrLstructStructunpackjoin) rUcharschars2padfoldnuls foldspacespaddingwordswordchunkss r% _85encoder0s  a % qM ! ! #Aw!mG   MM&CFaK0 1 8 8 ;E !  $ td TZ%7ddfn%dbj4'()TBY !   !s ": qAF2JBZ '*r 88F !s:3C#)rwrapcolradobec tHtddDcgc]}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) N!vTrDrCrrJr1 ) _a85chars2rPr- _a85charsr _A85STARTmaxrLappendr_A85END) rUrrrrrRrTresultrs r%rrHs &*/C.9.QUA4[.9 '0Dy!)Qq1u)uyD q)ZdJ GF V#5aa1 CK9;9aAK(9 ; 6":"W, c"F# ' M%:D;sC3C8C>s )rr ignorecharsc2 t|}|rS|jtstdj t|j t r|dd}n|dd}tjdj}g}|j}g}|j}|j} |dzD]} d| cxkrdkrEnnB|| t|dk(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)Nz1Ascii85 encoded byte sequences must end with {!r}rD!Isuuuurur>rrzAscii85 overflowzzz inside Ascii85 5-tuplesyzy inside Ascii85 5-tuples zNon-Ascii85 digit found: %cr1rH)r&endswithrrformat startswithrrrpackrclearrLerrorr)rUrrrpackIrmdecoded_appendcurr curr_append curr_clearxrprrs 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 +E66 FsU0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~c tBtDcgc]}t|fc}atDcgc]}tD]}||z c}}at tt|Scc}wcc}}wr7) _b85chars2 _b85alphabetr- _b85charsr)rUrrRrTs r%rrsb*67,QUA4[,7 '0Dy!)Qq1u)uyD Q :s 338Ds A A%c t&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) Nr>~rrrz#bad base85 character at position %dz+base85 overflow in hunk starting at byte %dr1)_b85decrarr&rLrrrrPr rrrr) rUrRrXroutrchunkrpjrs r%rrs~&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#ELrHrFc |jtx}rt|tkr^|jtt|z x}r;||z }t|tkr$|jtt|z x}r;tj|}|j ||jtx}ryyr7)read MAXBINSIZErLr*r+write)inputoutputr$nslines r%rrs;zz*% %! %!fz!UZZ 3q68I-J'Jr'J GA!fz!UZZ 3q68I-J'Jr'J""1% T zz*% %! %r1c |jx}r:tj|}|j||jx}r9yyr7)readliner*r4r)rrrr$s r%rrsF;.." "$ "    % 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)rXrUBz#expected single byte elements, not z from rCz(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?c t|g}tdt|tD]2}|||tz}|j t j |4dj|S)Nrr1)rrPrLrrr*r+r)r$piecesrRrs r%rrsca F 1c!fj )!a*n% h))%01* 88F r1cD t|tj|Sr7)rr*r4r#s r%rr'sBa   q !!r1c ddl}ddl}d|jdd} |j|jddd\}}t}D]8\}}|dk(rt}|dk(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) Nrzusage: zx [-h|-d|-e|-u] [file|-] -h: print this help message and exit -d, -u: decode -e: encode (default)rChdeurDz-ez-dz-uz-h-rb) sysgetoptargvrstderrstdoutprintexitrropenbufferstdin) rrusageoptsargsrfuncorTfs r%mainr.s+ }% E]]388AB<8 d D1 9Vd 9Vd 9Vd 9eElF   Q3 $q'4 A CJJ%% &!  SYY  szz001 <<ZZ  c  e   ! s#"C5E 5E8EE E__main__r7)NF)FN)F)FFF)8rrr*__all__r-rMrr&rrrrr.r:r<rr_B32_ENCODE_DOCSTRING_B32_DECODE_DOCSTRING_B32_DECODE_MAP01_DOCSTRINGrtrzrKr`rYrrr r__doc__r 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