-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.py
More file actions
49 lines (48 loc) · 1.29 KB
/
validate.py
File metadata and controls
49 lines (48 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import random
import re
def otp():
OTP=random.randint(1000,9999)
print(OTP,end="\n\n\n")
IP()
def captcha():
cap=input("Enter your captcha code: ")
Dig,low,up,spec=False,False,False,False
if len(cap)<4:
print("Invalid captcha, too short",end="\n\n\n")
captcha()
for char in cap:
if ord(char) >47 and ord(char)<58:
Dig=True
elif ord(char)>96 and ord (char)<123:
low=True
elif ord(char)>64 and ord(char)<91:
up=True
else:
spec=True
if Dig==True and low==True and up==True and spec==True:
print("Valid captcha",end="\n\n\n")
IP()
else:
print("Invalid captcha",end="\n\n\n")
IP()
'''
def valid(email):
regex=re.compile(r'([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{3,})+')
if re.fullmatch(regex,email):
print("Valid email",end="\n\n\n")
IP()
else:
print("Invalid email",end="\n\n\n")
IP()
'''
def IP():
print("1. OTP generator\n2. Captcha verifier")
choice=input("Enter your preferred option: ")
if choice=='1':
otp()
elif choice=='2':
captcha()
else:
print("Invalid option",end="\n\n\n")
IP()
IP()