Generate the Next Counter-Based One-Time Password (utils.hotp_next)
Declaration
code, err = utils.hotp_next(url[, secret])
Parameters
- url
String. HOTP URL in theotpauth://hotp/...format. - secret
String. Base32 secret. Optional. When provided, this secret is used to generate the code.
Returns
- code
String. Generated one-time password. - err
String. Error message returned when generation fails.
Description
Available after 2026-01-07.
Generate the next one-time password from an HOTP URL.
Useutils.hotp_counterif you need to specify the counter yourself.
The URL usually containssecret, and may also containdigitsandalgorithm.
algorithmcan beSHA1,SHA256, orSHA512.
Examples
local url = "otpauth://hotp/Demo:alice?secret=JBSWY3DPEHPK3PXP&issuer=Demo&digits=6&algorithm=SHA1"
local code, err = utils.hotp_next(url)
if code then
nLog(code)
else
nLog(err)
end