Skip to content

lgicc/totp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TOTP

Generate Random Secret.

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);

Convert manual to Base32.

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);

Generate TOTP

    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

About

Various functions to work with TOTP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published