Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/
Upload File :
Current File : //usr/lib/python2.7/base64.pyc



|_c@sdZddlZddlZddlZddddddd	d
ddd
dddgZgedD]Zee^qgZdZ	dZ
ddZddZ
dZdZdZdZi dd6dd6dd6d d!6d"d#6d$d%6d&d'6d(d)6d*d+6d,d-6d.d/6d0d16d2d36d4d56d6d76d8d96d:d;6d<d=6d>d?6d@dA6dBdC6dDdE6dFdG6dHdI6dJdK6dLdM6dNdO6dPdQ6dRdS6dTdU6dVdW6dXdY6ZejZejgeD]\ZZe^qZegejD]\ZZeeef^qZdZZedd[Zd\Zed]Zd^Z e d;d3Z!d_Z"d`Z#daZ$dbZ%dcZ&ddZ'e(dekre&ndS(fs/RFC 3548: Base16, Base32, Base64 Data EncodingsiNtencodetdecodetencodestringtdecodestringt	b64encodet	b64decodet	b32encodet	b32decodet	b16encodet	b16decodetstandard_b64encodetstandard_b64decodeturlsafe_b64encodeturlsafe_b64decodeitcCsJt}x*|jD]\}}||t|<qW|jdj|S(NR(t_translationtitemstordt	translatetjoin(tstaltcharsttranslationtktv((s/usr/lib/python2.7/base64.pyt
_translate scCsFtj|d }|dk	rBt|i|dd6|dd6S|S(slEncode a string using Base64.

    s is the string to encode.  Optional altchars must be a string of at least
    length 2 (additional characters are ignored) 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 string is returned.
    iit+it/N(tbinasciit
b2a_base64tNoneR(RRtencoded((s/usr/lib/python2.7/base64.pyR*s#cCsn|dk	r4t|id|d6d|d6}nytj|SWn"tjk
ri}t|nXdS(sDecode a Base64 encoded string.

    s is the string to decode.  Optional altchars must be a string of at least
    length 2 (additional characters are ignored) which specifies the
    alternative alphabet used instead of the '+' and '/' characters.

    The decoded string is returned.  A TypeError is raised if s were
    incorrectly padded or if there are non-alphabet characters present in the
    string.
    RiRiN(RRRt
a2b_base64tErrort	TypeError(RRtmsg((s/usr/lib/python2.7/base64.pyR;s(cCs
t|S(syEncode a string using the standard Base64 alphabet.

    s is the string to encode.  The encoded string is returned.
    (R(R((s/usr/lib/python2.7/base64.pyR
OscCs
t|S(sDecode a string encoded with the standard Base64 alphabet.

    s is the string to decode.  The decoded string is returned.  A TypeError
    is raised if the string is incorrectly padded or if there are non-alphabet
    characters present in the string.
    (R(R((s/usr/lib/python2.7/base64.pyRVscCs
t|dS(sEncode a string using a url-safe Base64 alphabet.

    s is the string to encode.  The encoded string is returned.  The alphabet
    uses '-' instead of '+' and '_' instead of '/'.
    s-_(R(R((s/usr/lib/python2.7/base64.pyR_scCs
t|dS(sDDecode a string encoded with the standard Base64 alphabet.

    s is the string to decode.  The decoded string is returned.  A TypeError
    is raised if the string is incorrectly padded or if there are non-alphabet
    characters present in the string.

    The alphabet uses '-' instead of '+' and '_' instead of '/'.
    s-_(R(R((s/usr/lib/python2.7/base64.pyR
gs	tAitJi	tSit3itBitKi
tTit4itCitLitUit5itDitMitVit6itEitNi
tWit7itFitOitXitGitPitYitHitQitZitIitRit2ic	Csg}tt|d\}}|rF|dd|7}|d7}nxt|D]}tjd||d|dd!\}}}||d@d>7}||d@d>7}|jt|d?t|d	?d
@t|d?d
@t|d?t|d?d
@t|d
?d
@t|d?t|d
@gqSWtj|}|dkrK|d dS|d
krc|d dS|dkr{|d dS|dkr|d dS|S(scEncode a string using Base32.

    s is the string to encode.  The encoded string is returned.
    itis!HHBiiiiiiiiiis======is====is===iit=(	tdivmodtlentrangetstructtunpacktextendt_b32tabtEMPTYSTRINGR(	Rtpartstquantatleftovertitc1tc2tc3R((s/usr/lib/python2.7/base64.pyRs6
.c
Cstt|d\}}|r0tdn|rVt|idd6|d6}n|rk|j}nd}tjd|}|rt|jd}|dkr|| }qng}d}d	}	x|D]}
tj	|
}|dkrtd
n|t|
|	>7}|	d8}	|	dkr|jtj
d|d}d	}	qqWtj
d|}|dkrd
}np|dkr|d }nW|dkr|d }n>|dkr|d }n%|dkr|d }ntd|j|tj|S(sGDecode a Base32 encoded string.

    s is the 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 string is returned.  A TypeError is raised if s were
    incorrectly padded or if there are non-alphabet characters present in the
    string.
    isIncorrect paddingR9t0t1is(?P<pad>[=]*)$tpadi#sNon-base32 digit foundis%010xRiiiiiiiiN(RFRGR"Rtuppertretsearchtgroupt_b32revtgetRtappendRt	unhexlifyRMR(
Rtcasefoldtmap01RORPtpadcharstmoRNtacctshifttctvaltlast((s/usr/lib/python2.7/base64.pyRsP 


	




cCstj|jS(scEncode a string using Base16.

    s is the string to encode.  The encoded string is returned.
    (RthexlifyRX(R((s/usr/lib/python2.7/base64.pyRscCsC|r|j}ntjd|r6tdntj|S(swDecode a Base16 encoded string.

    s is the 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 string is returned.  A TypeError is raised if s were
    incorrectly padded or if there are non-alphabet characters present in the
    string.
    s	[^0-9A-F]sNon-base16 digit found(RXRYRZR"RR_(RR`((s/usr/lib/python2.7/base64.pyR	s
iLcCsxtr|jt}|s"PnxCt|tkrg|jtt|}|sZPn||7}q%Wtj|}|j|qWdS(sEncode a file.N(tTruetreadt
MAXBINSIZERGRRtwrite(tinputtoutputRtnstline((s/usr/lib/python2.7/base64.pyRs	cCsCx<tr>|j}|sPntj|}|j|qWdS(sDecode a file.N(RjtreadlineRR Rm(RnRoRqR((s/usr/lib/python2.7/base64.pyR,s	cCs]g}xGtdt|tD]-}|||t!}|jtj|qWdj|S(s4Encode a string into multiple lines of base-64 data.iR(RHRGRlR^RRR(RtpiecesRQtchunk((s/usr/lib/python2.7/base64.pyR6s
cCs
tj|S(sDecode a string.(RR (R((s/usr/lib/python2.7/base64.pyR?sc	CsQddl}ddl}y#|j|jdd\}}WnD|jk
r}|j|_|GHd|jdGH|jdnXt}xj|D]b\}}|dkrt}n|d	krt}n|d
krt}n|dkrt	dSqW|r:|ddkr:t
|dd
}|||jWdQXn||j|jdS(sSmall test programiNitdeutsusage: %s [-d|-e|-u|-t] [file|-]
        -d, -u: decode
        -e: encode (default)
        -t: encode and decode string 'Aladdin:open sesame'iis-es-ds-us-tt-trb(tsystgetopttargvterrortstderrtstdouttexitRRttest1topentstdin(	RxRytoptstargsR#tfunctotatf((s/usr/lib/python2.7/base64.pyttestFs.#			cCs5d}t|}t|}|Gt|G|GHdS(NsAladdin:open sesame(RRtrepr(ts0ts1ts2((s/usr/lib/python2.7/base64.pyR`st__main__()t__doc__RYRIRt__all__RHt_xtchrRRMRRRRR
RRR
t_b32alphabetRRLtsortRRtdicttlongR\RtFalseRRR	tMAXLINESIZERlRRRRRRt__name__(((s/usr/lib/python2.7/base64.pyt<module>sZ%	
					
7	*J