Skip to content

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

Notifications You must be signed in to change notification settings

multiOTP/genOTP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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',
                        });