@eternaljs/otp-generator
Version:
An OTP (One-Time Password) generator is a crucial tool for enhancing security in digital transactions and logins. It generates unique, time-sensitive codes that serve as an additional layer of authentication. This adds an extra level of protection against
19 lines (18 loc) • 487 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateOTP = void 0;
function generateOTP(length = 6) {
try {
const digits = '0123456789';
let OTP = '';
for (let i = 1; i <= length; i++) {
const index = Math.floor(Math.random() * digits.length);
OTP = OTP + digits[index];
}
return OTP;
}
catch (error) {
return '854927';
}
}
exports.generateOTP = generateOTP;