
    [e
                     6    d Z ddlZddlZddZddZd ZddZy)z@
Utilities to encode and decode Base64.

.. versionadded:: 1.10
    Nc                 n    t        | t              r| j                  |      } t        j                  |       S )a`  Encode a string using Base64.

    If *s* is a text string, first encode it to *encoding* (UTF-8 by default).

    :param s: bytes or text string to be encoded
    :param encoding: encoding used to encode *s* if it's a text string
    :returns: Base64 encoded byte string (bytes)

    Use encode_as_text() to get the Base64 encoded string as text.
    )
isinstancestrencodebase64	b64encode)sencodings     ;/usr/lib/python3/dist-packages/oslo_serialization/base64.pyencode_as_bytesr      s-     !SHHXA    c                 >    t        | |      }|j                  d      S )ad  Encode a string using Base64.

    If *s* is a text string, first encode it to *encoding* (UTF-8 by default).

    :param s: bytes or text string to be encoded
    :param encoding: encoding used to encode *s* if it's a text string
    :returns: Base64 encoded text string (Unicode)

    Use encode_as_bytes() to get the Base64 encoded string as bytes.
    )r
   ascii)r   decode)r	   r
   encodeds      r   encode_as_textr   *   s     a(3G>>'""r   c                     t        | t              r| j                  d      } 	 t        j                  |       S # t
        j                  $ r}t        t        |            d}~ww xY w)a  Decode a Base64 encoded string.

    :param encoded: bytes or text Base64 encoded string to be decoded
    :returns: decoded bytes string (bytes)

    Use decode_as_text() to get the decoded string as text.

    A TypeError is raised if the input is invalid (or incorrectly padded).
    r   N)	r   bytesr   r   	b64decodebinasciiError	TypeErrorr   )r   es     r   decode_as_bytesr   9   sU     '5!..) ((>>  A s   8 A$AA$c                 :    t        |       }|j                  |      S )a5  Decode a Base64 encoded string.

    Decode the Base64 string and then decode the result from *encoding*
    (UTF-8 by default).

    :param encoded: bytes or text Base64 encoded string to be decoded
    :returns: decoded text string (bytes)

    Use decode_as_bytes() to get the decoded string as bytes.
    )r   r   )r   r
   decodeds      r   decode_as_textr   L   s     g&G>>(##r   )zutf-8)__doc__r   r   r   r   r   r    r   r   <module>r       s&       # &$r   