Your IP : 18.225.56.181


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/base64.cpython-34.pyo

�
e f�N�@szdZddlZddlZddlZddddddd	d
ddd
dddddddgZeefZdd�Zddd�Z	dddd�Z
dd�Zdd�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{tdt|�d�D]a}||||d�d�}|||d?||d	?d
@||d?d
@||d
@7}q�W|dkrGd
|dd�<n]|dkrfd|dd�<n>|dkr�d|dd�<n|dkr�d|dd�<nt|�S)zrEncode a byte string using Base32.

    s is the byte string to encode.  The encoded byte string is returned.
    NcSsg|]}t|f��qSr )r()�.0�ir r r!�
<listcomp>�s	zb32encode.<locals>.<listcomp>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|�}|jd�}|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�<q\|dkr�|dd�|dd�<q\|dkr!|dd�|dd�<q\|dkrJ|dd�|dd�<q\tjd��nt|�S)a]Decode a Base32 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.

    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.

    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.
    NcSsi|]\}}||�qSr r )r2�k�vr r r!�
<dictcomp>�s	zb32decode.<locals>.<dictcomp>�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!rss<~s~>c	s�t|t�s$t|�j�}nt|�d}|rL|d|}ntjdt|�d�j|�}����fdd�|D�}|r�|r�|ddkr��dd	|d<n|d
d|�|d<nd
j|�S)Nr?sz!%dIcseg|][}�r|rdn?�r7|dkr7dn'�|d�|dd�|d�qS)�zi    �yi�^	�Ui9r )r2Zword)�chars�chars2�foldnuls�
foldspacesr r!r40s	z_85encode.<locals>.<listcomp>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�tdt����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.<locals>.<listcomp>�!�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�currZcurr_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.<locals>.<listcomp>cSs'g|]}tD]}||�qqSr )�	_b85chars)r2r5r6r r r!r4�s	)r��_b85alphabet�
_b85chars2rm)r6rjr r r!r�s	c
Cs�tdkrCdgdax'tt�D]\}}|t|<q&Wnt|�}t|�d}|d|}g}tjd�j}xtdt|�d�D]�}|||d�}d}y'x |D]}|dt|}q�WWn\t	k
rDxDt|�D]6\}}t|dkrt
d||�d�qqW�YnXy|j||��Wq�tjk
r�t
d	|�d�Yq�Xq�Wd
j
|�}	|r�|	d|�}	n|	S)z Decode base85-encoded byte arrayN�r8�~z!Irraz#bad base85 character at position %dz+base85 overflow in hunk starting at byte %drf)�_b85decrTr�r"rFrgrhr�rJrrrwr�ri)
r6r3rKrk�outr��chunkr\�jrsr r r!r
�s<


�Lr?r@cCs�x|jt�}|sPnxCt|�tkra|jtt|��}|sTPn||7}qWtj|�}|j|�qWdS)z1Encode a file; input and output are binary files.N)�read�
MAXBINSIZErFr%r&�write)�input�outputr�ns�liner r r!r�scCs=x6|j�}|sPntj|�}|j|�qWdS)z1Decode a file; input and output are binary files.N)�readliner%r/r�)r�r�r�rr r r!r�scCs�yt|�}WnDtk
rV}z$d|jj}t|�|�WYdd}~XnX|jdkr�d|j|jjf}t|��n|jdkr�d|j|jjf}t|��ndS)	Nz"expected bytes-like object, not %srKr6�Bz-expected single byte elements, not %r from %sr#z(expected 1-D data, not %d-D data from %s)rKr6r�)rrrrr��ndim)r�m�err�msgr r r!�_input_type_checks"r�cCsjt|�g}xJtdt|�t�D]0}|||t�}|jtj|��q)Wdj|�S)zTEncode a bytestring into a bytestring containing multiple lines
    of base-64 data.rrf)r�rJrFr�rwr%r&ri)r�piecesr3r�r r r!rs
cCs)ddl}|jdtd�t|�S)zLegacy alias of encodebytes().rNz7encodestring() is a deprecated alias, use encodebytes()r>)�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_|ddkr_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
rrrrtrurxrmrrr�r�r�r�rr
ZMAXLINESIZEr�rrr�rr�rr�r�r�rr r r r!�<module>sh	(K$+C*	
	


?>