secure-otps
Version:
A cryptographically secure One Time Password(OTP) generator
16 lines (15 loc) • 487 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SecureOtps = void 0;
const crypto_1 = require("crypto");
class SecureOtps {
constructor(length) {
this.length = length;
this.min = parseInt("0".padEnd(length, "0"));
this.max = parseInt("9".padEnd(length, "9"));
}
generate() {
return (0, crypto_1.randomInt)(this.min, this.max).toString().padStart(this.length, "0");
}
}
exports.SecureOtps = SecureOtps;