U
    ”¼pdö  ã                   @   sˆ   d Z ddddddddgZd	d
lZd	d
lZd	d
lZd	dlmZ d	dlmZ eƒ Z	e	j
Ze	jZdd„ ZdZddd„Zddd„Zddd„Zd
S )zÙGenerate cryptographically strong pseudo-random numbers suitable for
managing secrets such as account authentication, tokens, and similar.

See PEP 506 for more information.
https://www.python.org/dev/peps/pep-0506/

ÚchoiceÚ	randbelowÚrandbitsÚSystemRandomÚtoken_bytesÚ	token_hexÚtoken_urlsafeÚcompare_digesté    N)r   )r   c                 C   s   | dkrt dƒ‚t | ¡S )z(Return a random int in the range [0, n).r	   zUpper bound must be positive.)Ú
ValueErrorÚ_sysrandZ
_randbelow)Zexclusive_upper_bound© r   ú/usr/lib/python3.8/secrets.pyr      s    é    c                 C   s   | dkrt } t | ¡S )zèReturn a random byte string containing *nbytes* bytes.

    If *nbytes* is ``None`` or not supplied, a reasonable
    default is used.

    >>> token_bytes(16)  #doctest:+SKIP
    b'\xebr\x17D*t\xae\xd4\xe3S\xb6\xe2\xebP1\x8b'

    N)ÚDEFAULT_ENTROPYÚosÚurandom©Únbytesr   r   r   r   #   s    
c                 C   s   t  t| ƒ¡ d¡S )a"  Return a random text string, in hexadecimal.

    The string has *nbytes* random bytes, each byte converted to two
    hex digits.  If *nbytes* is ``None`` or not supplied, a reasonable
    default is used.

    >>> token_hex(16)  #doctest:+SKIP
    'f9bf78b9a18ce6d46a0cd2b0b86df9da'

    Úascii)ÚbinasciiZhexlifyr   Údecoder   r   r   r   r   1   s    c                 C   s   t | ƒ}t |¡ d¡ d¡S )zþReturn a random URL-safe text string, in Base64 encoding.

    The string has *nbytes* random bytes.  If *nbytes* is ``None``
    or not supplied, a reasonable default is used.

    >>> token_urlsafe(16)  #doctest:+SKIP
    'Drmhze6EPcv0fN_81Bj-nA'

    ó   =r   )r   Úbase64Zurlsafe_b64encodeÚrstripr   )r   Útokr   r   r   r   >   s    
)N)N)N)Ú__doc__Ú__all__r   r   r   Zhmacr   Zrandomr   r   Zgetrandbitsr   r   r   r   r   r   r   r   r   r   r   Ú<module>   s&     þ

