
    J/i                     B    S SK r S SKrS SKrS SKJrJr   " S S\5      rg)    N)AnyOptionalc                       \ rS rSrSrS\R                  SS4S\S\S\	S\
\   S	\
\   S
S4S jjrS\S
\4S jrS
\4S jr\SS\S\S
\4S jj5       rSrg)OTP   z
Base class for OTP handlers.
   Nsdigitsdigestnameissuerreturnc                 v    X l         US:  a  [        S5      eX0l        Xl        U=(       d    SU l        XPl        g )N
   z!digits must be no greater than 10Secret)r
   
ValueErrorr   secretr   r   )selfr	   r
   r   r   r   s         C/home/james-whalen/.local/lib/python3.13/site-packages/pyotp/otp.py__init__OTP.__init__   s7     B;@AA$H	    inputc                    US:  a  [        S5      e[        R                  " U R                  5       U R	                  U5      U R
                  5      n[        UR                  5       5      nUS   S-  nX4   S-  S-  X4S-      S-  S	-  -  X4S
-      S-  S-  -  X4S-      S-  -  n[        SUSU R                  -  -  -   5      nX`R                  * S $ )z
:param input: the HMAC counter value to use as the OTP input.
    Usually either the counter, or the computed integer based on the Unix timestamp
r   zinput must be positive integer                           l    d(	 r   N)	r   hmacnewbyte_secretint_to_bytestringr   	bytearraystrr
   )r   r   hasher	hmac_hashoffsetcodestr_codes          r   generate_otpOTP.generate_otp   s    
 19=>>$**,d.D.DU.KT[[Yfmmo.	2$%",!$t+23!$t+12 !$t+- 	 ~DKK)?@A''r   c                     U R                   n[        U5      S-  nUS:w  a  USSU-
  -  -  n[        R                  " USS9$ )Nr#   r   =T)casefold)r   lenbase64	b32decode)r   r   missing_paddings      r   r'   OTP.byte_secret/   sG    f+/acQ011F66r   ipaddingc                     [        5       nU S:w  a!  UR                  U S-  5        U S-  n U S:w  a  M!  [        [        [        U5      5      R	                  US5      5      $ )zc
Turns an integer to the OATH specified
bytestring, which is fed to the HMAC
along with the secret
r   r    r#       )r)   appendbytesreversedrjust)r:   r;   results      r   r(   OTP.int_to_bytestring6   sX     1fMM!d(#!GA 1f Yx/066wFGGr   )r   r
   r   r   r   )r#   )__name__
__module____qualname____firstlineno____doc__hashlibsha1r*   intr   r   r   r0   r?   r'   staticmethodr(   __static_attributes__ r   r   r   r      s     ll" $  	
 sm  
 (# (# (&7U 7 HS H3 Hu H Hr   r   )r6   rI   r%   typingr   r   objectr   rN   r   r   <module>rQ      s        =H& =Hr   