
    VeIi                     J    d dl Z d dlZd dlZd dlmZmZ  G d de          ZdS )    N)AnyOptionalc                       e Zd ZdZdej        ddfdededede	e         de	e         d	dfd
Z
ded	efdZd	efdZeddeded	efd            ZdS )OTPz&
    Base class for OTP handlers.
       Nsdigitsdigestnameissuerreturnc                 z    || _         |dk    rt          d          || _        || _        |pd| _        || _        d S )N
   z!digits must be no greater than 10Secret)r	   
ValueErrorr
   secretr   r   )selfr   r	   r
   r   r   s         N/var/www/html/MCyber-Diagnostic/venv/lib/python3.11/site-packages/pyotp/otp.py__init__zOTP.__init__   sH     B;;@AAA$H	    inputc                    |dk     rt          d          t          j        |                                 |                     |          | j                  }t          |                                          }|d         dz  }||         dz  dz  ||dz            dz  d	z  z  ||d
z            dz  dz  z  ||dz            dz  z  }t          d|d| j        z  z  z             }|| j         d         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_otpzOTP.generate_otp   s   
 199=>>>$**,,d.D.DU.K.KT[YYfmmoo..	2$v%",!$t+23!$t+12 !$t+- 	 ~DK)?@AA''r   c                     | j         }t          |          dz  }|dk    r|dd|z
  z  z  }t          j        |d          S )Nr!   r   =T)casefold)r   lenbase64	b32decode)r   r   missing_paddings      r   r%   zOTP.byte_secret/   sM    f++/acQ011F6666r   r!   ipaddingc                     t                      }| dk    r#|                    | dz             | dz  } | dk    #t          t          t          |                                        |d                    S )z
        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)r6   r7   results      r   r&   zOTP.int_to_bytestring6   sp     1ffMM!d(###!GA 1ff Yx//0066wFFGGGr   )r!   )__name__
__module____qualname____doc__hashlibsha1r(   intr   r   r   r.   r;   r%   staticmethodr&    r   r   r   r      s
         l" $   	
 sm  
    (# (# ( ( ( (&7U 7 7 7 7 H HS H3 Hu H H H \H H Hr   r   )r3   rC   r#   typingr   r   objectr   rG   r   r   <module>rJ      sv                      =H =H =H =H =H& =H =H =H =H =Hr   