UNPKG

otp-generator-hg

Version:

Simple OTP generator and verifier

22 lines (19 loc) 396 B
function otpGenerator(len) { try { let otp = ""; for (let i = 0; i < len; i++) { otp += Math.floor(Math.random() * 10); } return otp; } catch (error) { throw error; } } function otpVerify(storedOtp, userOtp) { try { return storedOtp === userOtp; } catch (error) { throw error; } } module.exports = { otpGenerator, otpVerify };