HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/josepy/__pycache__/b64.cpython-310.pyc
o

h9Ra��@s4dZddlZdedefdd�Zdedefdd�ZdS)	a`JOSE Base64`_ is defined as:

  - URL-safe Base64
  - padding stripped

.. _`JOSE Base64`:
    https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-37#appendix-C

.. Do NOT try to call this module "base64", as it will "shadow" the
   standard library.

�N�data�returncCs"t|t�s	td��t�|��d�S)z�JOSE Base64 encode.

    :param data: Data to be encoded.
    :type data: bytes

    :returns: JOSE Base64 string.
    :rtype: bytes

    :raises TypeError: if ``data`` is of incorrect type

    zargument should be bytes�=)�
isinstance�bytes�	TypeError�base64�urlsafe_b64encode�rstrip�r�r�,/usr/lib/python3/dist-packages/josepy/b64.py�	b64encodes
rcCs`t|t�rz|�d�}Wntytd��wt|t�s!td��t�|ddt	|�d�S)a^JOSE Base64 decode.

    :param data: Base64 string to be decoded. If it's unicode, then
                 only ASCII characters are allowed.
    :type data: bytes or unicode

    :returns: Decoded data.
    :rtype: bytes

    :raises TypeError: if input is of incorrect type
    :raises ValueError: if input is unicode with non-ASCII characters

    �asciiz5unicode argument should contain only ASCII charactersz#argument should be a str or unicoder�)
r�str�encode�UnicodeEncodeError�
ValueErrorrrr�urlsafe_b64decode�lenrrrr
�	b64decode!s
��
r)�__doc__rrrrrrrr
�<module>s