Generate TOTP
- Installation
npm i gen-totp
// or
yarn add gen-totp
- Usage
const genTOTP = require('gen-totp');
const otp = genTOTP('test-key');
// that will return otp with length 6 numbers
const genTOTP = require('gen-totp');
const otp = genTOTP('test-key', { digits: 4 });
// that will return otp with length 4 numbers
Options
genTOTP take two parameters
key
this is a string that contains numbers, characters,_
and-
options
this an Objectdigits
this is the number of digits will returnperiod
this is the time to generate new otp after it (this by seconds)algorithm
this is algorithm to pure hash numbersthe complete Secure Hash Standard (SHA) family (SHA-1, SHA-224/256/384/512, SHA3-224/256/384/512, SHAKE128/256, cSHAKE128/256, and KMAC128/256) with HMAC. jssha