Skip to content

Commit 1e1ec86

Browse files
Merge pull request souravjain540#197 from Pooja1030/main
Added a OTP generator code in python
2 parents c0e4b58 + daab69d commit 1e1ec86

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

OTP generator.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import math
3+
import random
4+
import smtplib
5+
digits = "012456789"
6+
OTP = ""
7+
for i in range(4):
8+
OTP += digits[math.floor(random.random() * 10)]
9+
msg = str(OTP) + "Your OTP is"
10+
11+
s = smtplib.SMTP('smtp.gmail.com', 587)
12+
s.starttls()
13+
14+
emailid = "receiver's id"
15+
s.login("sender's id", "google app password")
16+
s.sendmail("sender's id", emailid, msg)
17+
a = input("Enter the OTP >>: ")
18+
if a == OTP:
19+
print("Verified")
20+
else:
21+
print("Incorrect OTP")
22+
s.quit()

0 commit comments

Comments
 (0)