https://github.com/authlib/otpauth
Implements two-step verification of HOTP/TOTP. Also known as one time password.
https://github.com/authlib/otpauth
otp otpauth
Last synced: about 2 months ago
JSON representation
Implements two-step verification of HOTP/TOTP. Also known as one time password.
- Host: GitHub
- URL: https://github.com/authlib/otpauth
- Owner: authlib
- License: bsd-3-clause
- Created: 2013-06-09T11:06:59.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2025-05-09T11:11:27.000Z (9 months ago)
- Last Synced: 2025-06-01T05:24:04.805Z (8 months ago)
- Topics: otp, otpauth
- Language: Python
- Homepage: https://otp.authlib.org
- Size: 140 KB
- Stars: 139
- Watchers: 11
- Forks: 20
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

One time password implementations in Python. HOTP and TOTP.
[](https://github.com/authlib/otpauth/actions/workflows/tests.yml)
[](https://pypi.org/project/otpauth)
[](https://codecov.io/gh/authlib/otpauth)
[](https://sonarcloud.io/summary/new_code?id=authlib_otpauth)
[](https://sonarcloud.io/summary/new_code?id=authlib_otpauth)
## Usage
A quick and simple usage of ``HOTP``:
```python
import otpauth
totp = otpauth.HOTP(b"user-secret")
# generate a code for now
code: int = totp.generate()
# you may want to convert it to string
str_code: str = totp.string_code(code)
# verify the code
totp.verify(code) # => True
totp.verify(str_code) # => True
```
## Install
Install with pip:
```shell
pip install otpauth
```
## Useful links
- Documentation: https://otp.authlib.org/
- Blog: https://blog.authlib.org/
- Twitter: https://twitter.com/authlib
## Copyright
2013, Hsiaoming Yang. Under BSD-3 license.