forked from bytesenseidk/Login-System
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
79 lines (70 loc) · 1.8 KB
/
main.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
import sys
import time
import getpass
from Login import Login
from SignUp import SignUp
from Encryption import Encrypt
def login():
while True:
os.system("cls")
print("[ LOGIN ]")
username = input("ENTER USERNAME >> ")
password = getpass.getpass("ENTER PASSWORD >> ")
user = Login(username, password)
if user.valid_user():
print("Login Successful!")
time.sleep(1)
break
else:
print("Login Unsuccessful, try again..")
time.sleep(1)
continue
def sign_up():
while True:
os.system("cls")
print("[ SIGN UP ]")
username = input("ENTER USERNAME >> ")
if SignUp.valid_username(username):
break
else:
print("Username Taken, try again..")
time.sleep(1)
continue
password = getpass.getpass("ENTER PASSWORD >> ")
user = SignUp(username, password)
user.save()
os.system("cls")
print("Account Added")
time.sleep(1)
if __name__ == "__main__":
userlist = "users.txt"
user_file = Encrypt(userlist)
os.system("cls")
functions = {
"1": login,
"2": sign_up
}
while True:
try:
user_file.decryption()
except:
pass
os.system("cls")
print("[ LOGIN SYSTEM ]\n"
"[0] Exit\n"
"[1] LOGIN\n"
"[2] SIGN UP\n")
choice = input(" >> ")
if choice == "0":
break
try:
os.system("cls")
function = functions[choice]
function()
except:
os.system("cls")
print("Enter valid option please...")
time.sleep(1)
continue
user_file.encryption()