Security & Identity · zero-dependency · MIT

larztotp

TOTP/HOTP two-factor auth.

Time- and counter-based one-time passwords per RFC 6238/4226, plus provisioning URIs — the exact codes any authenticator app produces, built on this stack's own real SHA-256 (the HMAC-SHA256 variant many authenticator apps support).

larzscript pkg install totp
View on GitHub →Learn the stack

What you get

Try it

import "totp" as totp
let secret = "JBSWY3DPEHPK3PXP"
let code = totp.hotp_generate(secret, 42)
print(code)
print(totp.hotp_verify(secret, 42, code))
print(totp.provisioning_uri(secret, "ada@example.com", "MyApp"))
Output
167840
true
otpauth://totp/MyApp:ada%40example.com?secret=JBSWY3DPEHPK3PXP&algorithm=SHA256&digits=6&period=30&issuer=MyApp

Why it's in the Larz Stack

larztotp is a real Larzscript package (larzscript pkg install totp) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.