
    VeIi0                         d dl Z d dlmZ d dlmZmZmZ d dlmZm	Z	m
Z
 	 	 	 	 	 	 ddededee         dee         d	ee         d
ee         dee         dee         defdZdededefdZdS )    N)compare_digest)DictOptionalUnion)quote	urlencodeurlparsesecretnameinitial_countissuer	algorithmdigitsperiodimagereturnc                 &   |du}|duo|dk    }	|duo|dk    }
|duo|dk    }|rdnd}d}d| i}t          |          }|t          |          d	z   |z   }||d
<   |r||d<   |	r|                                |d<   |
r||d<   |r||d<   |rOt          |          }|j        dk    s|j        r|j        s"t          d                    |                    ||d<   |                    ||t          |          	                    dd                    }|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totpzotpauth://{0}/{1}?{2}r
   :r   counterr   r   r   httpsz{} is not a valid urlr   +z%20)
r   upperr	   schemenetlocpath
ValueErrorformatr   replace)r
   r   r   r   r   r   r   r   is_initial_count_presentis_algorithm_setis_digits_setis_period_setotp_typebase_uriurl_argslabel	image_uriuris                     P/var/www/html/MCyber-Diagnostic/venv/lib/python3.11/site-packages/pyotp/utils.py	build_urir/      su   F  -D8 !,Df1D$&66Q;M$&76R<M1=vvvH&H2:F1CH$KKEf#e+# ,+ 2 ) 1 1 $# $# "UOO	w&&i.>&in&4;;IFFGGG!
//(E9X+>+>+F+FsE+R+R
S
SCJ    s1s2c                     t          j        d|           } t          j        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.
    NFKCzutf-8)unicodedata	normalizer   encode)r1   r2   s     r.   strings_equalr8   M   sP     
	vr	*	*B		vr	*	*B"))G,,bii.@.@AAAr0   )NNNNNN)r5   hmacr   typingr   r   r   urllib.parser   r   r	   strintr/   boolr8    r0   r.   <module>r@      sE             ( ( ( ( ( ( ( ( ( ( 3 3 3 3 3 3 3 3 3 3 $( #  C CC
C C=C SM	C
 }C SMC SMC C=C 	C C C CLBc Bs Bt B B B B B Br0   