B
    h
                 @   sD   d dl Z d dlmZmZ ddlmZ ddlmZ G dd deZdS )    N)AnyOptional   )utils)OTPc            	       s   e Zd ZdZdejdddfeeee	e e	e edd fddZ
eedd	d
ZeeedddZde	e e	e e	e e	e edddZ  ZS )HOTPz.
    Handler for HMAC-based OTP counters.
       Nr   )sdigitsdigestnameissuerinitial_countreturnc                s    || _ t j|||||d 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
        )r	   r
   r   r   r   N)r   super__init__)selfr	   r
   r   r   r   r   )	__class__ GC:\Users\sanjo\AppData\Local\Qlobot\Launcher\ext_packages\pyotp\hotp.pyr      s    
zHOTP.__init__)countr   c             C   s   |  | j| S )zz
        Generates the OTP for the given count.

        :param count: the OTP HMAC counter
        :returns: OTP
        )Zgenerate_otpr   )r   r   r   r   r   at   s    zHOTP.at)otpcounterr   c             C   s   t 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   Zstrings_equalstrr   )r   r   r   r   r   r   verify"   s    zHOTP.verify)r   r   issuer_nameimager   c          	   C   s@   t j| j|r|n| j|r|n| j|r(|n| j|  j| j|d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   Z	build_urisecretr   r   r   r   r
   )r   r   r   r   r   r   r   r   provisioning_uri+   s    zHOTP.provisioning_uri)NNNN)__name__
__module____qualname____doc__hashlibsha1r   intr   r   r   r   boolr   r    __classcell__r   r   )r   r   r      s   ,	   r   )	r%   typingr   r    r   r   r   r   r   r   r   r   <module>   s   