@multiotp/genotp

1.1.1 • Public • Published

genOTP

NPMV

Generic 2FA OTP generator (OATH/HOTP, OATH/TOTP, mOTP)

Features


Installation

yarn add @multiotp/genotp

or

npm install --save @multiotp/genotp

Examples

const OTP = require('./genotp')

let options = {
  algorithm: 'sha1', //sha1 (sha256|sha512 will be implemented later)
  bias:      0,      // for TOTP and mOTP only, time bias, in seconds
  counter:   0,      // HOTP counter
  digits:    6,      // 6|8   (number of digits)
  period:    30,     // 30|60 (for TOTP only, in seconds)
  pincode:   '',     // for mOTP only
  secret:    '3132333435363738393031323334353637383930',
  seedtype:  'hex',  // hex|base32|bin (secret seed format)
  type:      'hotp', // totp|hotp|motp (otp type)
  values:    1,      // number of values to return
}

const otp = new OTP(options);

console.log(otp.generate());
const OTP = require('./genotp')

const otp = new OTP();
console.log(otp.generate({type: 'hotp',
                          secret: '12345678901234567890',
                          seedtype: 'bin',
                        });
const OTP = require('./genotp')

const otp = new OTP();
console.log(otp.generate({type: 'motp',
                          secret: '1234567890abcdef',
                          pincode: '1234',
                        });

Package Sidebar

Install

npm i @multiotp/genotp

Weekly Downloads

42

Version

1.1.1

License

LGPL-3.0-or-later

Unpacked Size

23.6 kB

Total Files

4

Last publish

Collaborators

  • hilitec