Python: module otp

otp | index /tmp/makerelease-pwman-python.NVQhFLFA/pwman-python-2.8/libpwman/otp.py

# HOTP/TOTP support
# Copyright (c) 2019-2023 Michael Büsch <m@bues.ch>
# Licensed under the GNU/GPL version 2 or later.

Modules
binascii | hashlib | hmac | time

Classes
|  | builtins.Exception(builtins.BaseException) OtpError
class OtpError(builtins.Exception)
| HOTP/TOTP exception.
| Method resolution order: OtpError builtins.Exception builtins.BaseException builtins.object Data descriptors defined here: __weakref__ list of weak references to the object (if defined) Methods inherited from builtins.Exception: __init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. Static methods inherited from builtins.Exception: __new__(*args, **kwargs) from builtins.type Create and return a new object. See help(type) for accurate signature. Methods inherited from builtins.BaseException: __delattr__(self, name, /) Implement delattr(self, name). __getattribute__(self, name, /) Return getattr(self, name). __reduce__(...) Helper for pickle. __repr__(self, /) Return repr(self). __setattr__(self, name, value, /) Implement setattr(self, name, value). __setstate__(...) __str__(self, /) Return str(self). add_note(...) Exception.add_note(note) -- add a note to the exception with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self. Data descriptors inherited from builtins.BaseException: __cause__ exception cause __context__ exception context __dict__ __suppress_context__ __traceback__ args

Functions
|  | hotp(key, counter, nrDigits=6, hmacHash='SHA1') HOTP - An HMAC-Based One-Time Password Algorithm. key: The HOTP key. Either raw bytes or a base32 encoded string. counter: The HOTP counter integer. nrDigits: The number of digits to return. Can be 1 to 8. hmacHash: The name string of the hashing algorithm. Returns the calculated HOTP token string. totp(key, nrDigits=6, hmacHash='SHA1', t=None) TOTP - Time-Based One-Time Password Algorithm. nrDigits: The number of digits to return. Can be 1 to 8. hmacHash: The name string of the hashing algorithm. t: Optional; the time in seconds. Uses time.time(), if not given. Returns the calculated TOTP token string.

Data
|  | __all__ = ['OtpError', 'hotp', 'totp']