Ńň
7mČKc           @   sÇ  d  Z  d d k Z d d k Z d d k Z d d d d d d d	 d
 d d d d d d g Z g  Z e d  D] Z e e e  qk [ Z	 d Z
 d   Z d d  Z d d  Z d   Z d   Z d   Z d   Z h  d d 6d d 6d d 6d  d! 6d" d# 6d$ d% 6d& d' 6d( d) 6d* d+ 6d, d- 6d. d/ 6d0 d1 6d2 d3 6d4 d5 6d6 d7 6d8 d9 6d: d; 6d< d= 6d> d? 6d@ dA 6dB dC 6dD dE 6dF dG 6dH dI 6dJ dK 6dL dM 6dN dO 6dP dQ 6dR dS 6dT dU 6dV dW 6dX dY 6Z e i   Z e i   g  Z e D] \ Z Z e e qŮ[ Z e g  Z e i   D] \ Z Z e e e e  f q	[  Z dZ   Z e d d[  Z  d\   Z! e d]  Z" d^ Z# e# d; d3 Z$ d_   Z% d`   Z& da   Z' db   Z( dc   Z) dd   Z* e+ de j o e)   n d S(f   s/   RFC 3548: Base16, Base32, Base64 Data Encodingsi˙˙˙˙Nt   encodet   decodet   encodestringt   decodestringt	   b64encodet	   b64decodet	   b32encodet	   b32decodet	   b16encodet	   b16decodet   standard_b64encodet   standard_b64decodet   urlsafe_b64encodet   urlsafe_b64decodei   t    c         C   sJ   t  } x* | i   D] \ } } | | t |  <q W|  i d i |   S(   NR   (   t   _translationt   itemst   ordt	   translatet   join(   t   st   altcharst   translationt   kt   v(    (    s   /usr/lib/python2.6/base64.pyt
   _translate    s
     c         C   sH   t  i |   d  } | d j	 o$ t | h | d d 6| d d 6 S| S(   sl  Encode 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.
    i˙˙˙˙i    t   +i   t   /N(   t   binasciit
   b2a_base64t   NoneR   (   R   R   t   encoded(    (    s   /usr/lib/python2.6/base64.pyR   *   s    $c         C   sr   | d j	 o) t |  h d | d 6d | d 6 }  n y t i |   SWn$ t i j
 o } t |   n Xd S(   s  Decode 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.
    R   i    R   i   N(   R   R   R   t
   a2b_base64t   Errort	   TypeError(   R   R   t   msg(    (    s   /usr/lib/python2.6/base64.pyR   ;   s    )c         C   s
   t  |   S(   sy   Encode a string using the standard Base64 alphabet.

    s is the string to encode.  The encoded string is returned.
    (   R   (   R   (    (    s   /usr/lib/python2.6/base64.pyR
   O   s    c         C   s
   t  |   S(   s  Decode 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.6/base64.pyR   V   s    c         C   s   t  |  d  S(   sš   Encode 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.6/base64.pyR   _   s    c         C   s   t  |  d  S(   sD  Decode 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.6/base64.pyR   g   s    	t   Ai    t   Ji	   t   Si   t   3i   t   Bi   t   Ki
   t   Ti   t   4i   t   Ci   t   Li   t   Ui   t   5i   t   Di   t   Mi   t   Vi   t   6i   t   Ei   t   Ni   t   Wi   t   7i   t   Fi   t   Oi   t   Xi   t   Gi   t   Pi   t   Yi   t   Hi   t   Qi   t   Zi   t   Ii   t   Ri   t   2i   c   	      C   sĄ  g  } t  t |   d  \ } } | o  |  d d | 7}  | d 7} n xŰ t |  D]Í } t i d |  | d | d d ! \ } } } | | d @d >7} | | d @d >7} | i t | d ?t | d	 ?d
 @t | d ?d
 @t | d ?t | d ?d
 @t | d ?d
 @t | d ?t | d
 @g  qU Wt i |  } | d j o | d  d S| d j o | d  d S| d j o | d  d S| d j o | d  d S| S(   sc   Encode a string using Base32.

    s is the string to encode.  The encoded string is returned.
    i   t    i   s   !HHBi   i   i   i   i   i   i   i   i   iú˙˙˙s   ======iü˙˙˙s   ====iý˙˙˙s   ===i   i˙˙˙˙t   =(	   t   divmodt   lent   ranget   structt   unpackt   extendt   _b32tabt   EMPTYSTRINGR   (	   R   t   partst   quantat   leftovert   it   c1t   c2t   c3R   (    (    s   /usr/lib/python2.6/base64.pyR      s8     .c         C   s#  t  t |   d  \ } } | o t d   n | o! t |  h d d 6| d 6 }  n | o |  i   }  n d } t i d |   } | o5 t | i d   } | d j o |  |  }  qĹ n g  } d } d	 }	 x |  D] }
 t i	 |
  } | d j o t d
   n | t |
 |	 >7} |	 d 8}	 |	 d j  o* | i t i d |   d } d	 }	 qŢ qŢ Wt i d |  } | d j o
 d } ny | d j o | d  } n^ | d j o | d  } nC | d j o | d  } n( | d j o | d  } n t d   | i |  t i |  S(   sG  Decode 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.
    i   s   Incorrect paddingR9   t   0t   1i    s   (?P<pad>[=]*)$t   padi#   s   Non-base32 digit foundi   s   %010xR   i   i˙˙˙˙i   iţ˙˙˙i   iý˙˙˙i   iü˙˙˙N(   RF   RG   R"   R   t   uppert   ret   searcht   groupt   _b32revt   getR   t   appendR   t	   unhexlifyRM   R   (   R   t   casefoldt   map01RO   RP   t   padcharst   moRN   t   acct   shiftt   ct   valt   last(    (    s   /usr/lib/python2.6/base64.pyR   ą   sR    ! 

c         C   s   t  i |   i   S(   sc   Encode a string using Base16.

    s is the string to encode.  The encoded string is returned.
    (   R   t   hexlifyRX   (   R   (    (    s   /usr/lib/python2.6/base64.pyR   ű   s    c         C   sG   | o |  i    }  n t i d |   o t d   n t i |   S(   sw  Decode 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]s   Non-base16 digit found(   RX   RY   RZ   R"   R   R_   (   R   R`   (    (    s   /usr/lib/python2.6/base64.pyR	     s
    iL   c         C   s   x t  o |  i t  } | p Pn xG t |  t j  o3 |  i t t |   } | p Pn | | 7} q( Wt i |  } | i |  q Wd S(   s   Encode a file.N(   t   Truet   readt
   MAXBINSIZERG   R   R   t   write(   t   inputt   outputR   t   nst   line(    (    s   /usr/lib/python2.6/base64.pyR      s      c         C   sG   x@ t  o8 |  i   } | p Pn t i |  } | i |  q Wd S(   s   Decode a file.N(   Rj   t   readlineR   R    Rm   (   Rn   Ro   Rq   R   (    (    s   /usr/lib/python2.6/base64.pyR   ,  s     c         C   s]   g  } xG t  d t |   t  D]- } |  | | t !} | i t i |   q Wd i |  S(   s4   Encode a string into multiple lines of base-64 data.i    R   (   RH   RG   Rl   R^   R   R   R   (   R   t   piecesRQ   t   chunk(    (    s   /usr/lib/python2.6/base64.pyR   6  s     c         C   s   t  i |   S(   s   Decode a string.(   R   R    (   R   (    (    s   /usr/lib/python2.6/base64.pyR   ?  s    c          C   sO  d d k  }  d d k } y# | i |  i d d  \ } } WnF | i j
 o7 } |  i |  _ | GHd |  i d GH|  i d  n Xt } xr | D]j \ } } | d j o
 t } n | d	 j o
 t } n | d
 j o
 t } n | d j o t	   d Sq W| o2 | d d j o! | t
 | d d  |  i  n | |  i |  i  d S(   s   Small test programi˙˙˙˙Ni   t   deuts   usage: %s [-d|-e|-u|-t] [file|-]
        -d, -u: decode
        -e: encode (default)
        -t: encode and decode string 'Aladdin:open sesame'i    i   s   -es   -ds   -us   -tt   -t   rb(   t   syst   getoptt   argvt   errort   stderrt   stdoutt   exitR    R   t   test1t   opent   stdin(   Rx   Ry   t   optst   argsR#   t   funct   ot   a(    (    s   /usr/lib/python2.6/base64.pyt   testF  s.    #  
 
 
  	!c          C   s5   d }  t  |   } t |  } |  Gt |  G| GHd  S(   Ns   Aladdin:open sesame(   R   R   t   repr(   t   s0t   s1t   s2(    (    s   /usr/lib/python2.6/base64.pyR   _  s    t   __main__(,   t   __doc__RY   RI   R   t   __all__t   _[1]RH   t   _xt   chrR   RM   R   R   R   R   R
   R   R   R   t   _b32alphabetR   RL   t   sortt   _[2]R   R   t   dictt   _[3]t   longR\   R   t   FalseR   R   R	   t   MAXLINESIZERl   R    R   R   R   R   R   t   __name__(    (    (    s   /usr/lib/python2.6/base64.pyt   <module>   sZ   -	
					
'?	*J			
					