-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
70 lines (48 loc) · 1.85 KB
/
Copy pathapp.py
File metadata and controls
70 lines (48 loc) · 1.85 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
60
61
62
63
64
65
66
67
68
69
70
import hashlib
import os
while True:
print("\n")
print("=== 🛡️ ULTRA SECURE SYSTEM (with SALT) 🛡️ ===")
print("1. Signup")
print("2. Login")
print("3. Exit")
choice = input("Enter choice: ")
if choice == "1":
print("--- REGISTER ---")
u_name = input("Username: ")
p_word = input("Password: ")
salt = os.urandom(4).hex()
salted_password = p_word + salt
h_pw = hashlib.sha256(salted_password.encode()).hexdigest()
f = open("logs.txt", "a")
f.write(u_name + "," + salt + "," + h_pw + "\n")
f.close()
print("✅ Account Created with Salt protection!")
elif choice == "2":
print("--- LOGIN ---")
check_user = input("Username: ")
check_pass = input("Password: ")
f = open("logs.txt", "r")
found = False
for line in f:
data = line.strip().split(",")
stored_user = data[0]
if stored_user == check_user:
found = True
stored_salt = data[1]
stored_hash = data[2]
check_mix = check_pass + stored_salt
check_new_hash = hashlib.sha256(check_mix.encode()).hexdigest()
if check_new_hash == stored_hash:
print("✅ ACCESS GRANTED! You are the Boss.")
else:
print("❌ WRONG PASSWORD!")
break
f.close()
if not found:
print("❌ USER NOT FOUND!")
elif choice == "3":
print("Bye!")
break
else:
print("Invalid choice")