HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/pyotp/__pycache__/totp.cpython-310.pyc
o

��h�@s`ddlZddlZddlZddlZddlmZmZmZddlm	Z	ddl
mZGdd�de�ZdS)�N)�Any�Optional�Union�)�utils)�OTPcs�eZdZdZ					ddedededeed	eed
eddf�fdd
�
Zd de	ee
j
fdedefdd�Zdefdd�Zd!dedee
j
dede
fdd�Z	d"deedeedeedefdd�Zde
j
defdd�Z�ZS)#�TOTPz.
    Handler for time-based OTP counters.
    �N��s�digits�digest�name�issuer�interval�returncs.|durtj}||_t�j|||||d�dS)a�
        :param s: secret in base32 format
        :param interval: the time interval in seconds for OTP. This defaults to 30.
        :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)rrr
rr)�hashlib�sha1r�super�__init__)�selfrrr
rrr��	__class__��@/usr/local/CyberPanel/lib/python3.10/site-packages/pyotp/totp.pyrsz
TOTP.__init__r�for_time�counter_offsetcCs0t|tj�stj�t|��}|�|�|�|�S)a
        Accepts either a Unix timestamp integer or a datetime object.

        To get the time until the next timecode change (seconds until the current OTP expires), use this instead:

        .. code:: python

            totp = pyotp.TOTP(...)
            time_remaining = totp.interval - datetime.datetime.now().timestamp() % totp.interval

        :param for_time: the time to generate an OTP for
        :param counter_offset: the amount of ticks to add to the time counter
        :returns: OTP value
        )�
isinstance�datetime�
fromtimestamp�int�generate_otp�timecode)rrrrrr�at'szTOTP.atcCs|�|�tj����S)zL
        Generate the current time OTP

        :returns: OTP value
        )r!r"r�now)rrrrr$:szTOTP.now�otp�valid_windowc	Csl|dur	tj��}|r)t||d�D]}t�t|�t|�||���r&dSqdSt�t|�t|�|���S)ah
        Verifies the OTP passed in against the current time OTP.

        :param otp: the OTP to check against
        :param for_time: Time to check OTP at (defaults to now)
        :param valid_window: extends the validity to this many counter ticks before and after the current one
        :returns: True if verification succeeded, False otherwise
        NrTF)rr$�ranger�
strings_equal�strr#)rr%rr&�irrr�verifyBs	
�zTOTP.verify�issuer_name�imagec	Cs8tj|j|r|n|j|r|n|j|��j|j|j|d�S)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

        )r�	algorithmr�periodr-)r�	build_uri�secretrrr
rr)rrr,r-rrr�provisioning_uriVs
�zTOTP.provisioning_uricCs6|jrtt�|���|j�Stt�|���|j�S)z�
        Accepts either a timezone naive (`for_time.tzinfo is None`) or
        a timezone aware datetime as argument and returns the
        corresponding counter value (timecode).

        )	�tzinfor �calendar�timegm�utctimetupler�time�mktime�	timetuple)rrrrrr"msz
TOTP.timecode)r	NNNr
)r)Nr)NNN)�__name__�
__module__�__qualname__�__doc__r)r rrrrrr#r$�boolr+r2r"�
__classcell__rrrrrsH��������""����
�r)
r4rrr7�typingrrr�rr%rrrrrr�<module>s