Documents for @litert/otp / TOTP / createGenerator
Function: createGenerator()
createGenerator(
key
,digits
,period
,digest
):IGenerator
Defined in: TOTP.ts:96
Create a TOTP code generator function using configuration.
NOTES:
- Not all authenticator apps support digits other than
6
.- Not all authenticator apps support
SHA256
orSHA512
.- Not all authenticator apps support period other than
30
seconds.
Parameters
key
The key of TOTP (Buffer or BASE32-encoded string).
string
| Buffer
<ArrayBufferLike
>
digits
number
= cL.DEFAULT_DIGITS
The output width of OTP [default: 6
].
period
number
= cL.DEFAULT_PERIOD
The code generation interval of TOTP, in second. [default: 30
]
digest
EDigest
= cL.DEFAULT_DIGEST
The digest algorithm used to generate the TOTP code [default: SHA1
].
Returns
The TOTP code generator function.
Throws
If the key
, digits
, or period
is invalid.
Throws
If the digits
or period
is out of range.