-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
59 lines (42 loc) · 1.27 KB
/
Copy pathmain.py
File metadata and controls
59 lines (42 loc) · 1.27 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
50
51
52
53
54
55
56
57
58
59
import hashlib
import getpass
# Simple database (dictionary)
users = {
"amit": hashlib.sha256("password123".encode()).hexdigest(),
"admin": hashlib.sha256("admin123".encode()).hexdigest(),
}
def hash_password(password):
return hashlib.sha256(password.encode()).hexdigest()
def login():
print("=" * 40)
print(" LOGIN SYSTEM")
print("=" * 40)
username = input("Username: ")
password = getpass.getpass("Password: ")
if username not in users:
print("\n❌ User does not exist.")
return
if users[username] == hash_password(password):
print(f"\n✅ Welcome {username}!")
dashboard(username)
else:
print("\n❌ Incorrect password.")
def dashboard(username):
while True:
print("\n===== DASHBOARD =====")
print("1. View Profile")
print("2. Settings")
print("3. Logout")
choice = input("Enter choice: ")
if choice == "1":
print(f"\nUsername : {username}")
print("Role : User")
elif choice == "2":
print("\nSettings page.")
elif choice == "3":
print("\nLogged out successfully.")
break
else:
print("Invalid choice.")
if __name__ == "__main__":
login()