Generate a One-Time Password (TOTP) in Larzscript
Generate and verify RFC 6238 time-based one-time codes - the same 6-digit codes an authenticator app shows.
totp.verify() checks a +/-1 time-step drift window, the same tolerance real authenticator flows need for clock skew.
larzscript pkg install totp
Code
import "totp" as totp let secret = "JBSWY3DPEHPK3PXP" let code = totp.generate(secret) print(code) print(totp.verify(secret, code))
Output
334803 true
Related
larztotpRFC 6238 one-time codes (HMAC-SHA256)→Make an HTTP GET Request in LarzscriptFetch a URL and read its status code and body - or parse a JSON API response directly.→Sign and Verify a Webhook Payload in LarzscriptSign an outgoing webhook payload with HMAC-SHA256, and verify an incoming one - the same shape real payment/webhook providers use.→Hash Data with SHA-256 in LarzscriptCompute a real SHA-256 hash and an HMAC-SHA256 message authentication code.→