usr/lib64/python2.7/base64.pyo000064400000026041147204505450011673 0ustar00 zfc@sdZddlZddlZddlZddlZddddddd d d d d dddgZgedD]Zee^qsZ dZ dZ ddZ ddZdZdZejddZejddZdZdZi dd6dd6d d!6d"d#6d$d%6d&d'6d(d)6d*d+6d,d-6d.d/6d0d16d2d36d4d56d6d76d8d96d:d;6d<d=6d>d?6d@dA6dBdC6dDdE6dFdG6dHdI6dJdK6dLdM6dNdO6dPdQ6dRdS6dTdU6dVdW6dXdY6dZd[6ZejZejgeD]\ZZe^qZegejD]\ZZeeef^q%Zd\Ze dd]Z!d^Z"e d_Z#d`Z$e$d=d5Z%daZ&dbZ'dcZ(ddZ)deZ*dfZ+e,dgkre*ndS(hs/RFC 3548: Base16, Base32, Base64 Data EncodingsiNtencodetdecodet encodestringt decodestringt b64encodet b64decodet b32encodet b32decodet b16encodet b16decodetstandard_b64encodetstandard_b64decodeturlsafe_b64encodeturlsafe_b64decodeitcCsJt}x*|jD]\}}||t|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. isis!HHBiiii iii iiis======is====is===iit=( tdivmodtlentrangetstructtunpacktextendt_b32tabt EMPTYSTRINGR( Rtpartstquantatleftovertitc1tc2tc3R((s/usr/lib64/python2.7/base64.pyRs6 .          c Cs tt|d\}}|r0tdn|rX|jtjdd|}n|rm|j}nd}tjd|}|rt|j d}|dkr|| }qng}d}d} x|D]} t j | } | dkrtd n|t | | >7}| d 8} | dkr|j tjd |d}d} qqWtjd |} |dkrd } np|d kr| 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 paddingt01R;is(?P[=]*)$tpadi#sNon-base32 digit foundis%010xRiiiiiiiiN(RGRHR"RRRtuppertretsearchtgroupt_b32revtgetRtappendRt unhexlifyRNR( Rtcasefoldtmap01RPRQtpadcharstmoROtacctshifttctvaltlast((s/usr/lib64/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/lib64/python2.7/base64.pyRscCsC|r|j}ntjd|r6tdntj|S(suDecode 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 is 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.7/base64.pyR s iLcCsxtr|jt}|s"PnxCt|tkrg|jtt|}|sZPn||7}q%Wtj|}|j|qWdS(sEncode a file.N(tTruetreadt MAXBINSIZERHRRtwrite(tinputtoutputRtnstline((s/usr/lib64/python2.7/base64.pyR$s cCsCx<tr>|j}|sPntj|}|j|qWdS(sDecode a file.N(RjtreadlineRR Rm(RnRoRqR((s/usr/lib64/python2.7/base64.pyR3s   cCs]g}xGtdt|tD]-}|||t!}|jtj|qWdj|S(s4Encode a string into multiple lines of base-64 data.iR(RIRHRlR^RRR(RtpiecesRRtchunk((s/usr/lib64/python2.7/base64.pyR=s cCs tj|S(sDecode a string.(RR (R((s/usr/lib64/python2.7/base64.pyRFsc CsQddl}ddl}y#|j|jdd\}}WnD|jk r}|j|_|GHd|jdGH|jdnXt}xj|D]b\}}|dkrt}n|d krt}n|d krt}n|d krt 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/lib64/python2.7/base64.pyttestMs.#     cCs5d}t|}t|}|Gt|G|GHdS(NsAladdin:open sesame(RRtrepr(ts0ts1ts2((s/usr/lib64/python2.7/base64.pyRgs  t__main__(-t__doc__RYRJRRt__all__RIt_xtchrRRNRRRRR R RR$R%R R t _b32alphabetRRMtsortRRtdicttlongR\RtFalseRRR t MAXLINESIZERlRRRRRRt__name__(((s/usr/lib64/python2.7/base64.pyts`       %        7 *J