
    J/ip
                     J    S SK r S SKJrJr  SSKJr  SSKJr   " S S\5      rg)    N)AnyOptional   )utils)OTPc                      ^  \ rS rSrSr     SS\S\S\S\\   S\\   S	\S
S4U 4S jjjr	S\S
\4S jr
S\S\S
\4S jr    SS\\   S	\\   S\\   S\\   S
\4
S jjrSrU =r$ )HOTP   z&
Handler for HMAC-based OTP counters.
Nsdigitsdigestnameissuerinitial_countreturnc                 V   > Uc  [         R                  nX`l        [        TU ]  XX4US9  g)aE  
: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          D/home/james-whalen/.local/lib/python3.13/site-packages/pyotp/hotp.pyr   HOTP.__init__   s-    " >\\F*1FfU    countc                 >    U R                  U R                  U-   5      $ )zZ
Generates the OTP for the given count.

:param count: the OTP HMAC counter
:returns: OTP
)generate_otpr   )r   r   s     r   atHOTP.at$   s        !3!3e!;<<r   otpcounterc                 r    [         R                  " [        U5      [        U R                  U5      5      5      $ )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   verifyHOTP.verify-   s)     ""3s8S1A-BCCr   issuer_nameimagec           
          [         R                  " U R                  U(       a  UOU R                  U(       a  UOU R                  U(       a  UOU R
                  U R                  5       R                  U R                  US9$ )a  
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_uriHOTP.provisioning_uri6   sX    * KK499+8-d>P>P"-;4;;kkm((;;
 	
r   )r   )   NNNr   )NNNN)__name__
__module____qualname____firstlineno____doc__r%   intr   r   r   r   boolr&   r.   __static_attributes____classcell__)r   s   @r   r	   r	      s    " $VV V 	V
 smV V V 
V V.= = =D# D D D #'+%)#
sm
  }
 c]	

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