
    L.j-W                        S r SSKrSSKrSSKr/ SQr\\4rS rS:S jr	S;S jr
S rS	 r\R                  S
S5      r\R                  SS
5      rS rS rSrSrSrSrSr0 r0 rS rS<S jrS r\R9                  SS9\l         S<S jr\R9                  S\S9\l         S r\R9                  SS9\l         S=S jr\R9                  SSS9\l         S r S=S jr!Sq"Sq#S r$S!r%S>S" jr&SSSSS#.S$ jr'SSS%S&.S' jr(S(r)Sq*Sq+Sq,S=S) jr-S* r.S+r/S,r0\R                  \/\0-   \)S-\1" \05      -  -   5      r2\R                  \)\/5      r3S. r4S/ r5S0r6\6S1-  S2-  r7S3 r8S4 r9S5 r:S6 r;S7 r<S8 r=\>S9:X  a  \=" 5         gg)?zDBase16, Base32, Base64 (RFC 3548), Base85 and Ascii85 data encodings    N)encodedecodeencodebytesdecodebytes	b64encode	b64decode	b32encode	b32decodeb32hexencodeb32hexdecode	b16encode	b16decode	b85encode	b85decode	a85encode	a85decode	z85encode	z85decodestandard_b64encodestandard_b64decodeurlsafe_b64encodeurlsafe_b64decodec                 F   [        U [        5      (       a   U R                  S5      $ [        U [
        5      (       a  U $  [        U 5      R                  5       $ ! [         a    [	        S5      ef = f! [         a$    [        SU R                  R                  -  5      S ef = f)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__ss    V/root/.local/share/uv/python/cpython-3.13.14-linux-x86_64-gnu/lib/python3.13/base64.py_bytes_from_decode_datar(   "   s    !S	U88G$$ ![!!K!}$$&& " 	USTT	U  K )+,;;+?+?@ AFJ	KKs   A  A2 A/2.B c                     [         R                  " U SS9nUbD  [        U5      S:X  d   [        U5      5       eUR	                  [
        R                  SU5      5      $ U$ )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lenrepr	translatebytes	maketrans)r&   altcharsencodeds      r'   r   r   3   sX     !!!U3G8}!14>1!  !ABBN    Fc                     [        U 5      n UbO  [        U5      n[        U5      S:X  d   [        U5      5       eU R                  [        R                  US5      5      n [        R                  " XS9$ )a  Decode 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+   r,   )strict_mode)r(   r/   r0   r1   r2   r3   r-   
a2b_base64)r&   r4   validates      r'   r   r   A   sc    $ 	 "A*848}!14>1!KK%89q77r6   c                     [        U 5      $ )zjEncode bytes-like object s using the standard Base64 alphabet.

The result is returned as a bytes object.
)r   r%   s    r'   r   r   [   s    
 Q<r6   c                     [        U 5      $ )a=  Decode 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.
)r   r%   s    r'   r   r   b   s     Q<r6   r,   s   -_c                 >    [        U 5      R                  [        5      $ )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
'/'.
)r   r1   _urlsafe_encode_translationr%   s    r'   r   r   p   s     Q<!!"=>>r6   c                 X    [        U 5      n U R                  [        5      n [        U 5      $ )a  Decode 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(   r1   _urlsafe_decode_translationr   r%   s    r'   r   r   y   s'     	 "A	/0AQ<r6   zK
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                    U [         ;  aE  U  Vs/ s H  n[        U45      PM     nnU VVs/ s H  oC  H  oTU-   PM	     M     snn[         U '   S n[        U[        5      (       d  [	        U5      R                  5       n[        U5      S-  nU(       a  USSU-
  -  -   n[        5       n[        R                  n[         U    n	[        S[        U5      S5       H8  nU" XUS-    5      n
XyU
S-	     XS-	  S-     -   XS-	  S-     -   XS-     -   -  nM:     US:X  a  S	US
S & O#US:X  a  SUSS & OUS:X  a  SUSS & OUS:X  a  SUSS & [        U5      $ s  snf s  snnf )N       r         i  
      s   ======ir+   s   ====   s   ===      =)_b32tab2r2   r   r   r    r!   r/   	bytearrayint
from_bytesrange)alphabetr&   ib32tabableftoverr5   rQ   b32tab2cs              r'   
_b32encoder[      s{    x'/0x!%+x0-3DVV!eVeVDa%%qM!!#1vzHX&&kGJx G1c!fa qAE{#AG$"W-./"W-./ I&' 	 ! 1} 	Q	Q	Q>; 1Ds
   EEc                    U [         ;  a'  [        U 5       VVs0 s H  u  pEXT_M	     snn[         U '   [        U5      n[        U5      S-  (       a  [        R
                  " S5      eUbR  [        U5      n[        U5      S:X  d   [        U5      5       eUR                  [        R                  SSU-   5      5      nU(       a  UR                  5       n[        U5      nUR                  S5      nU[        U5      -
  n[        5       n[         U    n	[        S[        U5      S5       H3  n
XU
S-    nSn U H  nUS-  X   -   nM     XR                  S5      -  nM5     US-  (       d  US
;  a  [        R
                  " S5      eU(       a3  U(       a,  WSU-  -  nUR                  S5      nSSU-  -
  S-  nUS U USS & [        U5      $ s  snnf ! [         a    [        R
                  " S	5      S ef = f)N   zIncorrect paddingrG   s   01   OrL   r   rB   zNon-base32 digit found>   r   rG   rI   rK      +   )_b32rev	enumerater(   r/   r-   Errorr0   r1   r2   r3   upperrstriprO   rR   KeyErrorto_bytes)rS   r&   casefoldmap01kvlpadcharsdecodedb32revrT   quantaaccrZ   lastrX   s                   r'   
_b32decodert      s    w.7.AB.AdaQT.AB"A
1vznn011 '.5zQ+U+KKte|<=GGI 	AA	A3q6zHkGXF1c!fa a!e	Eax69,  	<<?" ! 	1u/nn011GH||AX%!+IX>O C8  	E..!9:D	Es   G2G"G/c                 "    [        [        U 5      $ N)r[   _b32alphabetr%   s    r'   r	   r	      s    lA&&r6   base32)encodingc                 $    [        [        XU5      $ rv   )rt   rw   )r&   ri   rj   s      r'   r
   r
      s    lA77r6   )ry   
extra_argsc                 "    [        [        U 5      $ rv   )r[   _b32hexalphabetr%   s    r'   r   r      s    oq))r6   	base32hexc                 "    [        [        X5      $ rv   )rt   r}   r&   ri   s     r'   r   r     s    oq33r6    c                 J    [         R                  " U 5      R                  5       $ )zKEncode the bytes-like object s using Base16 and return a bytes object.
    )r-   hexlifyre   r%   s    r'   r   r     s     A$$&&r6   c                     [        U 5      n U(       a  U R                  5       n [        R                  " SU 5      (       a  [        R
                  " S5      e[        R                  " U 5      $ )aj  Decode 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]zNon-base16 digit found)r(   re   researchr-   rd   	unhexlifyr   s     r'   r   r     sN     	 "AGGI	yyq!!nn566a  r6   s   <~s   ~>c                    [        U [        5      (       d  [        U 5      R                  5       n [	        U 5      * S-  nU(       a  U SU-  -   n [
        R                  " S[	        U 5      S-  -  5      R                  U 5      nU Vs/ s H<  nU(       a	  U(       d  SO(U(       a  US:X  a  SOX(S-     X(S-  S	-     -   XS-     -   PM>     n	nU(       a'  U(       d   U	S
   S:X  a  US   S-  U	S
'   U	S
   S U*  U	S
'   SR                  U	5      $ s  snf )NrK   rC   z!%dI   zi       yi^	 U   i9  rM   r   rB   r6   )	r   r   r    r!   r/   structStructunpackjoin)
rW   charschars2padfoldnuls
foldspacespaddingwordswordchunkss
             r'   	_85encoder   .  s   a%%qM!!#Aw!mGMM&CFaK0188;E  !
  $ td TZ%7dfn%bj4'()BY !
    ! s":qAF2JBZ	'*r
88F!s   AD	)r   wrapcolr   adobec                L   [         cP  [        SS5       Vs/ s H  n[        U45      PM     snq[         VV s/ s H  n[          H  oU -   PM	     M     sn nq [	        W [        [         USU5      nU(       a	  [
        U-   nU(       a}  [        U(       a  SOSU5      n[        S[        U5      U5       Vs/ s H	  nXuXR-    PM     nnU(       a&  [        US   5      S-   U:  a  UR                  S5        S	R                  U5      nU(       a	  U[        -  nU$ s  snf s  sn nf s  snf )
a  Encode 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 encoding used in PDF.

If wrapcol is non-zero, insert a newline (b'\n') character after at most
every wrapcol characters.

pad controls whether zero-padding applied to the end of the input
is fully retained in the output encoding, as done by btoa,
producing an exact multiple of 5 bytes of output.

adobe controls whether the encoded byte sequence is framed with <~
and ~>, as in a PostScript base-85 string literal.  Note that
while ASCII85Decode streams in PDF documents must be terminated
with ~>, they must not use a leading <~.

!   v   Tr+   rG   r   rM   r6      
)
_a85chars2rR   r2   	_a85charsr   	_A85STARTmaxr/   appendr   _A85END)	rW   r   r   r   r   rT   rV   resultr   s	            r'   r   r   F  s   . */C.9.QUA4[.9	'0Dy!))Q1u)uyD
q)ZdJGFV#5aa1 CK9;9a AK(9 	 ;6":"W,c"F#'M% :D;s   DD4D!s    	
)r   r   ignorecharsc                   [        U 5      n U(       a]  U R                  [        5      (       d  [        SR	                  [        5      5      eU R                  [        5      (       a  U SS n OU SS n [        R                  " S5      R                  n/ nUR                  n/ nUR                  nUR                  n	U S-    H  n
SU
s=::  a  S::  aJ  O  OGU" U
5        [        U5      S	:X  a.  S
nU H  n
SU-  U
S-
  -   nM      U" U" U5      5        U	" 5         MX  MZ  U
S:X  a  U(       a  [        S5      eU" S5        M|  U(       a"  U
S:X  a  U(       a  [        S5      eU" S5        M  X;   a  M  [        SU
-  5      e   SR                  U5      nS[        U5      -
  nU(       a  USU*  nU$ ! [        R                   a    [        S5      Sef = f)a  Decode 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 Ascii85
encoding used in PDF and PostScript.

adobe controls whether the <~ and ~> markers are present. While
the leading <~ is not required, the input must end with ~>, or a
ValueError is raised.

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}r+   N!Is   uuuur   u   rB   r   r   zAscii85 overflowz   zz inside Ascii85 5-tuples       y   zy inside Ascii85 5-tuples       zNon-Ascii85 digit found: %cr6   rK   )r(   endswithr   r   format
startswithr   r   r   packr   clearr/   errorr   )rW   r   r   r   packIro   decoded_appendcurrcurr_append
curr_clearxrr   r   r   s                 r'   r   r   r  s   $ 	 "Azz'"""F7O  <<	""!BA#2A
 MM$$$EG^^ND++KJ\a"7"N4yA~As(a"f-C C"5:.   '\ !;<<;'AL !;<<./:Q>??1 4 XXgF#d)mG	'"M- || C$%78dBCs   >F''!GsU   0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~c                     [         cJ  [         Vs/ s H  n[        U45      PM     snq[         VV s/ s H  n[          H  oU -   PM	     M     sn nq [	        W [        [         U5      $ s  snf s  sn nf )a  Encode bytes-like object b in base85 format and return a bytes object.

The input is padded with b' ' so its length is a multiple of 4
bytes before encoding.  If pad is true, all the resulting
characters are retained in the output, which will always be a
multiple of 5 bytes.
)
_b85chars2_b85alphabetr2   	_b85charsr   )rW   r   rT   rV   s       r'   r   r     s]     *67,QUA4[,7	'0Dy!))Q1u)uyD
Q	:s33 8Ds
   A(A-c                    [         c$  S/S-  n[        [        5       H	  u  p#X!U'   M     Uq [        U 5      n [	        U 5      * S-  nU SU-  -   n / n[
        R                  " S5      R                  n[        S[	        U 5      S5       H=  nXUS-    nSn U H  nUS-  [         U   -   nM      UR                  U" U5      5        M?     S
R                  U5      n
U(       a  U
SU*  n
U
$ ! [         a1    [        U5       H   u  p[         U   b  M  [        SX)-   -  5      Se   e f = f! [
        R                   a    [        S	U-  5      Sef = f)ziDecode the base85-encoded bytes-like object or ASCII string b

The result is returned as a bytes object.
N   rB      ~r   r   r   z#bad base85 character at position %dz+base85 overflow in hunk starting at byte %dr6   )_b85decrc   r   r(   r/   r   r   r   rR   r"   r   r   r   r   )rW   
b85dec_tmprT   rZ   r   outr   chunkrr   jr   s              r'   r   r     st     Vc\
l+DAqM ,"AAw!mG	D7NA
CMM$$$E1c!fa AE
	Bh+ 	,JJuSz" !$ XXc]F	'"M  	!%(1:%$%J'(u&. /489 ) 	 || 	,J ! "'+,	,s   C',D%'"D"D"%$E	sU   0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#s   ;_`|~rC   c                 >    [        U 5      R                  [        5      $ )zCEncode bytes-like object b in z85 format and return a bytes object.)r   r1   _z85_encode_translationr%   s    r'   r   r   	  s    Q<!!"9::r6   c                     [        U 5      n U R                  [        5      n  [        U 5      $ ! [         a.  n[	        UR
                  S   R                  SS5      5      SeSnAff = f)zfDecode the z85-encoded bytes-like object or ASCII string b

The result is returned as a bytes object.
r   base85z85N)r(   r1   _z85_decode_translationr   r   argsreplace)r&   es     r'   r   r     sa    
 	 "A	+,AG| G**8U;<$FGs   
- 
A%)A  A%L   rK   rI   c                    U R                  [        5      =n(       a  [        U5      [        :  ai  U R                  [        [        U5      -
  5      =n(       aA  X#-  n[        U5      [        :  a*  U R                  [        [        U5      -
  5      =n(       a  MA  [        R                  " U5      nUR                  U5        U R                  [        5      =n(       a  M  gg)z1Encode a file; input and output are binary files.N)read
MAXBINSIZEr/   r-   r.   write)inputoutputr&   nslines        r'   r   r      s    zz*%
%!
%!fz!UZZ
3q68I-J'Jr'JGA !fz!UZZ
3q68I-J'Jr'J""1%T	 zz*%
%!
%
%r6   c                     U R                  5       =n(       aA  [        R                  " U5      nUR                  U5        U R                  5       =n(       a  M@  gg)z1Decode a file; input and output are binary files.N)readliner-   r9   r   )r   r   r   r&   s       r'   r   r   )  sF    .."
"$
"%Q .."
"$
"
"r6   c                     [        U 5      nUR                  S;  a3  SUR                  < SU R                  R                  < 3n[        U5      eUR
                  S:w  a0  SUR
                  U R                  R                  4-  n[        U5      eg ! [         a*  nSU R                  R                  -  n[        U5      UeS nAff = f)Nz"expected bytes-like object, not %s)rZ   rW   Bz#expected single byte elements, not z from rG   z(expected 1-D data, not %d-D data from %s)r    r"   r#   r$   r   ndim)r&   merrmsgs       r'   _input_type_checkr   /  s    &qM 	xx&+,88Q[[5I5IKnvv{9+,661;;3G3G*HIn   &2Q[[5I5IIn#%&s   B 
C%C  Cc                     [        U 5        / n[        S[        U 5      [        5       H3  nXU[        -    nUR	                  [
        R                  " U5      5        M5     SR                  U5      $ )zREncode a bytestring into a bytes object containing multiple lines
of base-64 data.r   r6   )r   rR   r/   r   r   r-   r.   r   )r&   piecesrT   r   s       r'   r   r   ?  s^     aF1c!fj)a*n%h))%01 * 88Fr6   c                 D    [        U 5        [        R                  " U 5      $ )z8Decode a bytestring of base-64 data into a bytes object.)r   r-   r9   r%   s    r'   r   r   J  s    aq!!r6   c                  |   SSK n SSKnSU R                  S    S3n UR                  U R                  SS S5      u  p4[        nW H<  u  pxUS:X  a  [        nUS	:X  a  [        nUS
:X  a  [        nUS:X  d  M1  [        U5          g   W(       a>  US   S:w  a5  [        US   S5       n	U" XR
                  R                  5        SSS5        gU R                  R                  5       (       a:  SSKn
U R                  R                  R                  5       nU
R!                  U5      nOU R                  R                  nU" XR
                  R                  5        g! UR                   aC  nU R                  U l        [        U5        [        U5        U R                  S5         SnAGNgSnAff = f! , (       d  f       g= f)zSmall main programr   Nzusage: zx [-h|-d|-e|-u] [file|-]
        -h: print this help message and exit
        -d, -u: decode
        -e: encode (default)rG   hdeur+   z-ez-dz-uz-h-rb)sysgetoptargvr   stderrstdoutprintexitr   r   openbufferstdinisattyior   BytesIO)r   r   usageoptsr   r   funcorV   fr   datar   s                r'   mainr   Q  sa   } %  E]]388AB<8
 D9Vd9Vd9Vd9eElF	 
 Q3$q'4 AJJ%%& !  9999##((*DZZ%FYY%%FVZZ&&'- << ZZ
c
e	 ! s#   !E %F-F*'8F%%F*-
F;__main__rv   )NF)FN)F)FFF)?__doc__r   r   r-   __all__r2   rO   r   r(   r   r   r   r   r3   r>   r@   r   r   _B32_ENCODE_DOCSTRING_B32_DECODE_DOCSTRING_B32_DECODE_MAP01_DOCSTRINGrw   r}   rN   rb   r[   rt   r	   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   _z85alphabet_z85_b85_decode_diffr/   r   r   r   r   MAXLINESIZEr   r   r   r   r   r   r   r$    r6   r'   <module>r     s2   K 
  $ i K"84 $ooeU; #ooeU; ?$ 	   35
!F+\')00(0C	 8)00(3N 1 P	 *,33[3I 4 -33[?A 4 C '!* 	
	
0  %aU% *X  %E| FTE	

4 *XE   //''7S!5666   //,E ;
G  1na
 "(D zF r6   