Generic 2FA OTP generator (OATH/HOTP, OATH/TOTP, mOTP)
npm install @multiotp/genotpbash
yarn add @multiotp/genotp
`
or
`bash
npm install --save @multiotp/genotp
`
Examples
`javascript
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());
`
`javascript
const OTP = require('./genotp')
const otp = new OTP();
console.log(otp.generate({type: 'hotp',
secret: '12345678901234567890',
seedtype: 'bin',
});
`
`javascript
const OTP = require('./genotp')
const otp = new OTP();
console.log(otp.generate({type: 'motp',
secret: '1234567890abcdef',
pincode: '1234',
});
``