
    VeIip
                     R    d dl Z d dlmZmZ ddlmZ ddlmZ  G d de          ZdS )    N)AnyOptional   )utils)OTPc                        e Zd ZdZ	 	 	 	 	 ddedededee         d	ee         d
eddf fdZdedefdZ	dedede
fdZ	 	 	 	 ddee         d
ee         dee         dee         def
dZ xZS )HOTPz.
    Handler for HMAC-based OTP counters.
       Nr   sdigitsdigestnameissuerinitial_countreturnc                 ~    |t           j        }|| _        t                                          |||||           dS )a}  
        :param s: secret in base32 format
        :param initial_count: starting HMAC counter value, defaults to 0
        :param digits: number of integers in the OTP. Some apps expect this to be 6 digits, others support more.
        :param digest: digest function to use in the HMAC (expected to be SHA1)
        :param name: account name
        :param issuer: issuer
        N)r   r   r   r   r   )hashlibsha1r   super__init__)selfr   r   r   r   r   r   	__class__s          O/var/www/html/MCyber-Diagnostic/venv/lib/python3.11/site-packages/pyotp/hotp.pyr   zHOTP.__init__   sB    " >\F*1VFfUUUUU    countc                 <    |                      | j        |z             S )zz
        Generates the OTP for the given count.

        :param count: the OTP HMAC counter
        :returns: OTP
        )generate_otpr   )r   r   s     r   atzHOTP.at$   s        !3e!;<<<r   otpcounterc                     t          j        t          |          t          |                     |                              S )z
        Verifies the OTP passed in against the current counter OTP.

        :param otp: the OTP to check against
        :param counter: the OTP HMAC counter
        )r   strings_equalstrr   )r   r   r    s      r   verifyzHOTP.verify-   s1     "3s88S1A1A-B-BCCCr   issuer_nameimagec           	          t          j        | j        |r|n| j        |r|n| j        |r|n| j        |                                 j        | j        |          S )a5  
        Returns the provisioning URI for the OTP.  This can then be
        encoded in a QR Code and used to provision an OTP app like
        Google Authenticator.

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

        :param name: name of the user account
        :param initial_count: starting HMAC counter value, defaults to 0
        :param issuer_name: the name of the OTP issuer; this will be the
            organization title of the OTP entry in Authenticator
        :returns: provisioning URI
        )r   r   r   	algorithmr   r&   )r   	build_urisecretr   r   r   r   r   )r   r   r   r%   r&   s        r   provisioning_urizHOTP.provisioning_uri6   sc    * K,49+8P--d>P"->;;4;kkmm(;
 
 
 	
r   )r
   NNNr   )NNNN)__name__
__module____qualname____doc__r#   intr   r   r   r   boolr$   r+   __classcell__)r   s   @r   r	   r	      sp         " $V VV V 	V
 smV V V 
V V V V V V.= = = = = =D# D D D D D D #'+%)#
 
sm
  }
 c]	

 }
 

 
 
 
 
 
 
 
r   r	   )	r   typingr   r    r   r   r   r	    r   r   <module>r6      s                                K
 K
 K
 K
 K
3 K
 K
 K
 K
 K
r   