larztotp
TOTP/HOTP two-factor auth codes. Pure Python (stdlib), zero dependencies.
Generate and verify the 6-digit one-time passwords authenticator apps use (Google
Authenticator, Authy, 1Password), plus the provisioning otpauth:// URI for the
setup QR — all from the standard library, matching the RFC test vectors so codes
interoperate with every app.
from larztotp import TOTP
totp = TOTP.generate() # new random secret
uri = totp.provisioning_uri("alice@example.com", issuer="MyApp") # QR this
totp.verify(user_entered_code) # True / False
Why
- Standards-correct. HOTP (RFC 4226) and TOTP (RFC 6238), tested against the published RFC vectors — the codes match real authenticator apps exactly.
- Skew-tolerant, safe verify. A configurable time
windowaccepts a slightly off clock; comparison is constant-time. - Zero dependencies. Pure
hmac/hashlib/base64— nopyotp, nothing to install. A natural companion to larzcrypt.
Install
pip install larztotp
Usage
from larztotp import TOTP, hotp, totp, verify, generate_secret
t = TOTP.generate(); t.now(); t.verify(code, window=1)
t.provisioning_uri("bob@x.com", issuer="App")
# or the raw functions
secret = generate_secret()
hotp(secret, counter=0)
totp(secret) # current 6-digit code
verify(secret, code, window=1)
SHA256/SHA512 and 8-digit codes are supported via algorithm=/digits=.
Tests
python -m unittest discover -s tests -v # 15 tests incl. RFC 4226/6238 vectors
The Larz stack
One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter — see larzcrypt and larzid.
License
MIT © larz-scripter
Metadata
Release files for larztotp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| larztotp-0.1.0.tar.gz | 5.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| larztotp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.3 kB
Release files / larztotp-0.1.0.tar.gz
| Download URL | larztotp-0.1.0.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19abac2a505fa3721b51545ef518d6a812daacb0edb8325bc50d7039eee1db2d
|
|
BLAKE2b-256 checksum How to use checksums |
a2b8ff438a623164437a1f3e7b20342555209d1666e5751b24917a90af0b3a00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / larztotp-0.1.0-py3-none-any.whl
| Download URL | larztotp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f605c9aa9f6205dca272bfe4cfb64e30f780e6517c5f0cd85dd1a9b071731c7
|
|
BLAKE2b-256 checksum How to use checksums |
ed31598d7aaf020ac13984ba2a691cfd2ced7838f5e6d649bdf48eb337f04b58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for larztotp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.