otp.js 406 B

12345678910111213141516171819
  1. require('dotenv').config()
  2. // const {HOTP} = require('otpauth')
  3. // const coba = require('../utils/coba')
  4. // module.exports = new HOTP({
  5. // algorithm: 'SHA256',
  6. // digits: 6,
  7. // period: 30,
  8. // secret: 'tes'
  9. // })
  10. module.exports = (limit = 4) => {
  11. const digits = '0123456789'
  12. let OTP = ''
  13. for (let i = 0; i < limit; i++) {
  14. OTP += digits[Math.floor(Math.random() * 10)]
  15. }
  16. return OTP
  17. }