generate one-time password (OTP)
Program to generate one-time password (OTP)
One-time Passwords (OTP) is a password that is valid for only one login session or transaction in a computer or a digital device. Now a days OTP’s are used in almost every service like Internet Banking, online transactions etc. They are generally combination of 4 or 6 numeric digits or a 6-digit alphanumeric.
random() function can be used to generate random OTP which is predefined in random library. Let’s see how to generate OTP using Python.
Example #1 : Generate 4 digit Numeric OTP
Output:
Example #2: Generate alphanumeric OTP of length 6
Output:
Example #3: Using String constants
Output:
Reference : https://www.geeksforgeeks.org/python-program-to-generate-one-time-password-otp/?ref=rp
Last updated
Was this helpful?