HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/pyotp/__pycache__/utils.cpython-310.pyc
o

��h0�@s�ddlZddlmZddlmZmZmZddlmZm	Z	m
Z
						ddededeedeed	eed
eedeedeed
efdd�Z
deded
efdd�ZdS)�N)�compare_digest)�Dict�Optional�Union)�quote�	urlencode�urlparse�secret�name�
initial_count�issuer�	algorithm�digits�period�image�returncCs|du}|duo|dk}	|duo|dk}
|duo|dk}|r dnd}d}
d|i}t|�}|dur<t|�d	|}||d
<|rB||d<|	rJ|��|d<|
rP||d
<|rV||d<|rrt|�}|jdksg|jrg|jsntd�|���||d<|
�||t|��	dd��}|S)a�
    Returns the provisioning URI for the OTP; works for either TOTP or HOTP.

    This can then be encoded in a QR Code and used to provision the Google
    Authenticator app.

    For module-internal use.

    See also:
        https://github.com/google/google-authenticator/wiki/Key-Uri-Format

    :param secret: the hotp/totp secret used to generate the URI
    :param name: name of the account
    :param initial_count: starting counter value, defaults to None.
        If none, the OTP type will be assumed as TOTP.
    :param issuer: the name of the OTP issuer; this will be the
        organization title of the OTP entry in Authenticator
    :param algorithm: the algorithm used in the OTP generation.
    :param digits: the length of the OTP generated code.
    :param period: the number of seconds the OTP generator is set to
        expire every code.
    :param image: optional logo image url
    :returns: provisioning uri
    N�sha1���hotp�totpzotpauth://{0}/{1}?{2}r	�:r�counterr
rr�httpsz{} is not a valid urlr�+z%20)
r�upperr�scheme�netloc�path�
ValueError�formatr�replace)r	r
rrr
rrr�is_initial_count_present�is_algorithm_set�
is_digits_set�
is_period_set�otp_type�base_uri�url_args�label�	image_uri�uri�r,�A/usr/local/CyberPanel/lib/python3.10/site-packages/pyotp/utils.py�	build_uris4#r.�s1�s2cCs.t�d|�}t�d|�}t|�d�|�d��S)a
    Timing-attack resistant string comparison.

    Normal comparison using == will short-circuit on the first mismatching
    character. This avoids that by scanning the whole string, though we
    still reveal to a timing attack whether the strings are the same
    length.
    �NFKCzutf-8)�unicodedata�	normalizer�encode)r/r0r,r,r-�
strings_equalMs	r5)NNNNNN)r2�hmacr�typingrrr�urllib.parserrr�str�intr.�boolr5r,r,r,r-�<module>s<���������	
�F