ó
    ùŠÂjî	  ã                   ó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                 óÔ   • X l         US:”  a  [        S5      eX0l        U[        R                  [        R
                  4;   a  [        S5      eXl        U=(       d    SU l        XPl        g )Né
   z!digits must be no greater than 10zUselected digest function must generate digest size greater than or equals to 18 bytesÚSecret)	r
   Ú
ValueErrorr   ÚhashlibÚmd5Ú	shake_128Úsecretr   r   )Úselfr	   r
   r   r   r   s         Ú?/var/www/website/venv/lib/python3.13/site-packages/pyotp/otp.pyÚ__init__ÚOTP.__init__   sZ   € ð ŒØ�B‹;ÜÐ@ÓAÐAØŒØ”g—k‘k¤7×#4Ñ#4Ð5Ó5ÜÐtÓuÐuØŒØ×$˜HˆŒ	Ø�ó    Úinputc                 óÖ  • US:  a  [        S5      e[        R                  " U R                  5       U R	                  U5      U R
                  5      nUR                  S:  a  [        S5      e[        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é   zNdigest size is lower than 18 bytes, which will trigger error on otp generationéÿÿÿÿé   é   é   é   éÿ   é   é   é   é   l    d(	 r   N)
r   ÚhmacÚnewÚbyte_secretÚint_to_bytestringr   Údigest_sizeÚ	bytearrayÚstrr
   )r   r   ÚhasherÚ	hmac_hashÚoffsetÚcodeÚstr_codes          r   Úgenerate_otpÚOTP.generate_otp   s  € ð
 �1‹9ÜÐ=Ó>Ð>Ü—’˜$×*Ñ*Ó,¨d×.DÑ.DÀUÓ.KÈTÏ[É[ÓYˆØ×Ñ Ó"ÜÐmÓnÐnÜ˜fŸm™m›oÓ.ˆ	Ø˜2‘ Ñ$ˆàÑ Ñ%¨"Ñ,Ø !™Ñ$ tÑ+°Ñ2ñ3à !™Ñ$ tÑ+°Ñ1ñ2ð  !™Ñ$ tÑ+ñ-ð 	ô �~¨°°D·K±K±Ñ)?Ñ@Ó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_secret3   sG   € Ø—‘ˆÜ˜f›+¨™/ˆØ˜aÓØ�c˜Q Ñ0Ñ1Ñ1ˆFÜ×Ò °Ñ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_bytestring:   sX   € ô “ˆØ�1‹fØ�M‰M˜!˜d™(Ô#Ø�!‰GˆAð �1�fô ”Yœx¨Ó/Ó0×6Ñ6°wÀÓFÓGÐGr   )r   r
   r   r   r   )r'   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Úsha1r/   Úintr   r   r   r5   rD   r+   Ústaticmethodr,   Ú__static_attributes__© r   r   r   r      s­   † ñð Ø—l‘lØ"Ø $ñàðð ðð ð	ð
 �s‰mðð ˜‘ðð 
õð$( #ð (¨#ô (ð*7˜Uô 7ð ñH˜Sð H¨3ð H°uô Hó óHr   r   )r;   r   r)   Útypingr   r   Úobjectr   rR   r   r   Ú<module>rU      s!   ðÛ Û Û ß  ôAHˆ&õ AHr   