Your IP : 18.224.54.118
B
���_� � @ s d dl Z d dlZd dlmZmZ y d dlmZ d dlmZm Z W n e
k
rX eZY nX eeef ed�dd�Z
eeef ed�d d
�Zeed�dd�Zeed
�dd�Zeeef ed
�dd�Zeeed�dd�Zeed�dd�Zeed
�dd�Zeeed�dd�Zeeed�dd�ZdS ) � N)�Any�Union)�
EllipticCurve)�decode_dss_signature�encode_dss_signature)�value�returnc C s. t | t�r| �d�S t | t�r"| S td��d S )Nzutf-8zExpected a string value)�
isinstance�str�encode�bytes� TypeError)r � r �:/opt/alt/python37/lib/python3.7/site-packages/jwt/utils.py�force_bytes s
r )�inputr c C sB t | t�r| �d�} t| �d }|dkr8| dd| 7 } t�| �S )N�ascii� r � =)r r
r �len�base64�urlsafe_b64decode)r �remr r r �base64url_decode s
r c C s t �| ��dd�S )Nr � )r �urlsafe_b64encode�replace)r r r r �base64url_encode$ s r )�valr c C s0 | dk rt d��t| �}t|�dkr(d}t|�S )Nr zMust be a positive integer� )�
ValueError�bytes_from_intr r )r � int_bytesr r r �to_base64url_uint( s r# c C s* t | t�r| �d�} t| �}tj|dd�S )Nr �big)� byteorder)r r
r r �int�
from_bytes)r �datar r r �from_base64url_uint4 s
r) )�num� num_bytesr c C s$ dd| | f }t �|�d��}|S )Nz%0*x� r )�binascii�a2b_hexr )r* r+ Z
padded_hexZ
big_endianr r r �number_to_bytes<