AlkantarClanX12

Your IP : 3.145.196.150


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

�
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"cCsftj|�dd�}|dk	rbt|�dksItt|���|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�len�AssertionError�repr�	translate�bytes�	maketrans)r�altchars�encodedr r r!r3s
$FcCs�t|�}|dk	rft|�}t|�dksHtt|���|jtj|d��}n|r�tjd|�r�t	j
d��nt	j|�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.
    Nr$s+/s^[A-Za-z0-9+/]*={0,2}$zNon-base64 digit found)r"r(r)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 )r6�a�b)�b32tabr r!r8�s	�r�big��i��
r#s======�r$s====��s===�=i����������r%)�_b32tab2�_b32alphabetrrrrr(r,�	bytearray�int�
from_bytes�range)rZleftoverr/rKZb32tab2r7�cr )r;r!r�s4			+c
Cs�tdkr(dd�tt�D�ant|�}t|�drVtjd��n|dk	r�t|�}t|�dks�tt|���|j	t
jdd|��}n|r�|j�}nt|�}|j
d	�}|t|�}t�}t}x�td
t|�d�D]�}|||d�}d
}	y'x |D]}
|	d>||
}	qFWWn$tk
r�tjd�d�YnX||	jdd
�7}qW|r�|	d|K}	|	jdd
�}|dkr�|dd�|dd�<q�|dkr|dd�|dd�<q�|dkrE|dd�|dd�<q�|dkrn|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 )r6�k�vr r r!�
<dictcomp>�s	zb32decode.<locals>.<dictcomp>�zIncorrect paddingr#s01�OrDrr<zNon-base32 digit foundr=rCr$rBrAr%������rSrFrSrErS)�_b32rev�	enumeraterHr"r(r&r2r)r*r+r,r-�upper�rstriprIrL�KeyError�to_bytes)r�casefoldZmap01�lZpadchars�decodedZb32revr7Zquanta�accrM�lastr r r!r	�sL$"	

cCstj|�j�S)zrEncode a byte string using Base16.

    s is the byte string to encode.  The encoded byte string is returned.
    )r&ZhexlifyrW)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"rWr0�searchr&r2Z	unhexlify)rr[r 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)NrBsz!%dIcseg|][}�r|rdn?�r7|dkr7dn'�|d�|dd�|d�qS)�zi    �yi�^	�Ui9r )r6Zword)�chars�chars2�foldnuls�
foldspacesr r!r80s	z_85encode.<locals>.<listcomp>r#rarr<�r%r%r%r%)	rrrrr(�struct�StructZunpack�join)	r:rdre�padrfrg�paddingZwords�chunksr )rdrerfrgr!�	_85encode&s&

rorg�wrapcolrl�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,)r6r7r r r!r8Us	za85encode.<locals>.<listcomp>�!�vcSs'g|]}tD]}||�qqSr )�	_a85chars)r6r9r:r r r!r8Vs	Tr$r#cs$g|]}�||���qSr r )r6r7)�resultrpr r!r8^s	rrhs
r%)
rtrL�
_a85chars2ro�	_A85START�maxr(�appendrk�_A85END)r:rgrprlrqrnr )rurpr!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�urB�!rr<rcrrzAscii85 overflowNrazz inside Ascii85 5-tuplesrbzy inside Ascii85 5-tuples    zNon-Ascii85 digit found: %crhrTsuuuurr�u�z�y)r"�
startswithrw�endswithrzr�formatrirj�packry�clearr(�errorrk)r:rgrqr{�packIr]Zdecoded_append�currZcurr_appendZ
curr_clear�xr^rurmr 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,)r6r7r r r!r8�s	zb85encode.<locals>.<listcomp>cSs'g|]}tD]}||�qqSr )�	_b85chars)r6r9r:r r r!r8�s	)r��_b85alphabet�
_b85chars2ro)r:rlr 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�r<�~z!Irrcz#bad base85 character at position %dz+base85 overflow in hunk starting at byte %drh)�_b85decrVr�r"r(rirjr�rLrrryr�rk)
r:r7rMrm�outr��chunkr^�jrur r r!r
�s<


�LrBrCcCs�x|jt�}|sPnxCt|�tkra|jtt|��}|sTPn||7}qWtj|�}|j|�qWdS)z1Encode a file; input and output are binary files.N)�read�
MAXBINSIZEr(r&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&r3r�)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 %srMr:�Bz-expected single byte elements, not %r from %sr#z(expected 1-D data, not %d-D data from %s)rMr:r�)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.rrh)r�rLr(r�ryr&r'rk)r�piecesr7r�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&r3)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�or9�fr r r!�main5s0)
 			r�cCsdd}tt|��t|�}tt|��t|�}tt|��||ks`t�dS)NsAladdin:open sesame)r�r*rrr))Zs0�s1�s2r r r!r�Osr��__main__)2�__doc__r0rir&�__all__r,rIrr"rrrrr-r4r5rrrHrGrUrr	r
rrtrvrwrzrorrr�r�r�r�rr
ZMAXLINESIZEr�rrr�rr�rr�r�r�rr r r r!�<module>sh	(K$+C*