OTP Verification using Python
Steps to Create an OTP Verification System using Python:-
- 1.First, create a 6-digit random number.
- 2.Then store the number in a variable.
- 3.Then we need to write a program to send emails.
- 4.When sending email, we need to use OTP as a message.
- 5.Finally, we need to request two user inputs; first for the user’s email and then for the OTP that the user has received.
Source Code:-
| import os import math | |
| import random | |
| import smtplib | |
| digits="0123456789" | |
| OTP="" | |
| for i in range(6): | |
| OTP+=digits[math.floor(random.random()*10)] | |
| otp = OTP + " is your OTP" | |
| msg= otp | |
| s = smtplib.SMTP('smtp.gmail.com', 587) | |
| s.starttls() | |
| s.login("Your Gmail Account", "You app password") | |
| emailid = input("Enter your email: ") | |
| s.sendmail('&&&&&&&&&&&',emailid,msg) | |
| a = input("Enter Your OTP >>: ") | |
| if a == OTP: | |
| print("Verified") | |
| else: | |
| print("Please Check your OTP again") |
Comments
Post a Comment