Ńň §ÚęLc@sÇdZddkZddkZddkZddddddd d d d d dddgZgZedƒD]Zeeeƒqk[Z dZ d„Z dd„Z dd„Zd„Zd„Zd„Zd„Zh dd6dd6dd6d d!6d"d#6d$d%6d&d'6d(d)6d*d+6d,d-6d.d/6d0d16d2d36d4d56d6d76d8d96d:d;6d<d=6d>d?6d@dA6dBdC6dDdE6dFdG6dHdI6dJdK6dLdM6dNdO6dPdQ6dRdS6dTdU6dVdW6dXdY6ZeiƒZeiƒgZeD]\ZZeeqŮ[ZegZeiƒD]\ZZeeeeƒfq [ƒZdZ„Zedd[„Z d\„Z!ed]„Z"d^Z#e#d;d3Z$d_„Z%d`„Z&da„Z'db„Z(dc„Z)dd„Z*e+dejo e)ƒndS(fs/RFC 3548: Base16, Base32, Base64 Data Encodingsi˙˙˙˙Ntencodetdecodet encodestringt decodestringt b64encodet b64decodet b32encodet b32decodet b16encodet b16decodetstandard_b64encodetstandard_b64decodeturlsafe_b64encodeturlsafe_b64decodeitcCsJt}x*|iƒD]\}}||t|ƒ7}||d@d>7}|it|d?t|d ?d @t|d?d @t|d ?t|d ?d @t|d ?d @t|d?t|d @gƒqUWti|ƒ}|djo |d dS|d jo |d dS|djo |d dS|djo |d dS|S(scEncode a string using Base32. s is the string to encode. The encoded string is returned. itis!HHBiiii iii iiiú˙˙˙s======iü˙˙˙s====iý˙˙˙s===ii˙˙˙˙t=( tdivmodtlentrangetstructtunpacktextendt_b32tabt EMPTYSTRINGR( Rtpartstquantatleftovertitc1tc2tc3R((s/usr/lib64/python2.6/base64.pyR‡s8 .          c Cs#tt|ƒdƒ\}}|otdƒ‚n|o!t|hdd6|d6ƒ}n|o|iƒ}nd}tid|ƒ}|o5t|idƒƒ}|djo|| }qĹng}d}d } x|D]…} ti | ƒ} | djotd ƒ‚n|t| | >7}| d 8} | djo*|i t i d |ƒƒd}d } qŢqŢWt i d |ƒ} |djo d } ny|djo| d } n^|djo| d } nC|djo| d } n(|djo| d } n tdƒ‚|i | ƒti|ƒ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[=]*)$tpadi#sNon-base32 digit foundis%010xRii˙˙˙˙iiţ˙˙˙iiý˙˙˙iiü˙˙˙N(RFRGR"Rtuppertretsearchtgroupt_b32revtgetRtappendRt unhexlifyRMR( Rtcasefoldtmap01RORPtpadcharstmoRNtacctshifttctvaltlast((s/usr/lib64/python2.6/base64.pyRąsR!            cCsti|ƒiƒS(scEncode a string using Base16. s is the string to encode. The encoded string is returned. (RthexlifyRX(R((s/usr/lib64/python2.6/base64.pyRűscCsG|o|iƒ}ntid|ƒotdƒ‚nti|ƒ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/lib64/python2.6/base64.pyR s iLcCs”xto…|itƒ}|pPnxGt|ƒtjo3|itt|ƒƒ}|pPn||7}q(Wti|ƒ}|i|ƒqWdS(sEncode a file.N(tTruetreadt MAXBINSIZERGRRtwrite(tinputtoutputRtnstline((s/usr/lib64/python2.6/base64.pyRscCsGx@to8|iƒ}|pPnti|ƒ}|i|ƒqWdS(sDecode a file.N(RjtreadlineRR Rm(RnRoRqR((s/usr/lib64/python2.6/base64.pyR,s cCs]g}xGtdt|ƒtƒD]-}|||t!}|iti|ƒƒqWdi|ƒS(s4Encode a string into multiple lines of base-64 data.iR(RHRGRlR^RRR(RtpiecesRQtchunk((s/usr/lib64/python2.6/base64.pyR6s cCs ti|ƒS(sDecode a string.(RR (R((s/usr/lib64/python2.6/base64.pyR?sc CsOddk}ddk}y#|i|iddƒ\}}WnF|ij o7}|i|_|GHd|idGH|idƒnXt}xr|D]j\}}|djo t}n|d jo t}n|d jo t}n|d jo t ƒdSq‘W|o2|dd jo!|t |dd ƒ|iƒn||i |iƒdS(sSmall test programi˙˙˙˙Nitdeutsusage: %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#tfunctota((s/usr/lib64/python2.6/base64.pyttestFs.#       !cCs5d}t|ƒ}t|ƒ}|Gt|ƒG|GHdS(NsAladdin:open sesame(RRtrepr(ts0ts1ts2((s/usr/lib64/python2.6/base64.pyR_s  t__main__(,t__doc__RYRIRt__all__t_[1]RHt_xtchrRRMRRRRR R R R t _b32alphabetRRLtsortt_[2]RRtdictt_[3]tlongR\RtFalseRRR t MAXLINESIZERlRRRRR‡Rt__name__(((s/usr/lib64/python2.6/base64.pytsZ      -       '? *J