Default length is 20
import {generateSecret} from '@lgicc/totp';
// Generate Secret with Default length of 20
// Automatically converted to base32
const secret = generateSecret();
// Generate Secret with custom length
const customSecret = generateSecret(30);
To support Google Authenticator
import {generateSecret} from '@lgicc/totp';
import {toBase32} from '@lgicc/totp';
// Generate secret without automatic base32 convertion
const secretNoBase32 = generateSecret(20, false);
// Convert to secret to base32 manually
const secretBase32 = toBase32(secretNoBase32);
import {TOTP} from '@lgicc/totp';
import {generateSecret} from '@lgicc/totp';
// Generate Secret with Default Length of 20
const secret = generateSecret();
const totp = new TOTP(secret);
console.log(totp.generate());
// Verify TOTP
console.log(totp.verify('000000')); // inject your code instead of 000000