-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
244 lines (196 loc) · 12.7 KB
/
script.py
File metadata and controls
244 lines (196 loc) · 12.7 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# Student Record Management System
# Date Created: 05/03/2025
# Last Edited: 1st July, 2025
import time
import json
from hashlib import sha256
from os import system
from functionControl import ui, isQuitting as iq
from ReadUpdateDelete import updatePassword as updtPswrd
def timer(s):
while s:
time.sleep(1)
s -= 1
system("cls")
breakAll = False
try:
DEL_LINE = "\033[A\033[K"
WHITE = "\033[38;2;212;212;212m"
YELLOW = "\033[38;2;255;200m"
RED = "\033[38;2;200;0m"
lb = "\033[38;2;108;180;238m"
LIGHT_YELLOW = "\033[38;2;255;224;110m"
B = "\033[1m"
R = "\033[0m"
continuationSelector = ''
system("cls") if __import__("os").name == "nt" else system("clear")
hasUpper = False
hasSpecialSymbol = False
hasDigit = False
isPasswordCorrect = False
with open("password.json", "r") as xyz:
pswrdDict = json.load(xyz)
if pswrdDict["password"].strip() == "":
print("\n\nPassword must be at least 8 characters long")
print("Password must have alteast 1 upper case letter")
print(f"Password must have alteast 1 special symbol {YELLOW}(_, !, @, #, $, %, &){WHITE}")
print("Password must have alteast 1 digit\n\n")
while True:
pswrd = input(f"\nEnter a password: {YELLOW}")
print(f"{WHITE}", end="")
i = 0
if len(pswrd) >= 8:
for i in pswrd:
if i in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" and hasUpper == False:
hasUpper = True
i = 0
for i in pswrd:
if i in "_!@#$%&" and hasSpecialSymbol == False:
hasSpecialSymbol = True
i = 0
for i in pswrd:
if i in "1234567890" and hasDigit == False:
hasDigit = True
i = 0
if hasUpper == True and hasSpecialSymbol == True and hasDigit == True:
pswrd = sha256(pswrd.encode('utf-8')).hexdigest()
pswrd = sha256(pswrd.encode('utf-8')).hexdigest()
pswrd = sha256(pswrd.encode('utf-8')).hexdigest()
pswrdDict["password"] = pswrd
with open("password.json", "w") as xyz:
json.dump(pswrdDict, xyz, indent = 8)
print("\nPassword has been set!")
isPasswordCorrect = True
break
else:
if hasUpper == False:
print(f"{lb}Password must have alteast 1 upper case letter{WHITE}")
if hasSpecialSymbol == False:
print(f"{lb}Password must have alteast 1 special symbol {YELLOW}(_, !, @, #, $, %, &){WHITE}")
if hasDigit == False:
print(f"{lb}Password must have at least 1 number{WHITE}")
else:
print(f"{lb}Pasword must be at least 8 characters long{WHITE}")
else:
for i in range(3):
pswrd = input(f"Password (Attempt {i+1} of 3): {YELLOW}")
pswrd = sha256(pswrd.encode('utf-8')).hexdigest()
pswrd = sha256(pswrd.encode('utf-8')).hexdigest()
pswrd = sha256(pswrd.encode('utf-8')).hexdigest()
print(f"{WHITE}", end="")
with open("password.json", "r") as xyz:
pswrdDict = json.load(xyz)
if pswrdDict["password"] == pswrd:
isPasswordCorrect = True
break
else:
print(f"{lb}Invalid password{WHITE}\n")
isPasswordCorrect = False
if isPasswordCorrect == True:
print("Welcome!")
timer(3)
system("cls")
while True:
if (continuationSelector == 'cls' or continuationSelector == ''):
print(f"\n\n{B}School Manager{R}\n\n")
print(f"Enter {lb}1{WHITE} {LIGHT_YELLOW}→{WHITE} Access Grade {YELLOW}1{WHITE}")
print(f"Enter {lb}2{WHITE} {LIGHT_YELLOW}→{WHITE} Access Grade {YELLOW}2{WHITE}")
print(f"Enter {lb}3{WHITE} {LIGHT_YELLOW}→{WHITE} Access Grade {YELLOW}3{WHITE}")
print(f"Enter {lb}4{WHITE} {LIGHT_YELLOW}→{WHITE} Access Grade {YELLOW}4{WHITE}")
print(f"Enter {lb}5{WHITE} {LIGHT_YELLOW}→{WHITE} Access Grade {YELLOW}5{WHITE}")
print(f"Enter {lb}6{WHITE} {LIGHT_YELLOW}→{WHITE} Access Grade {YELLOW}6{WHITE}")
print(f"Enter {lb}7{WHITE} {LIGHT_YELLOW}→{WHITE} Access Grade {YELLOW}7{WHITE}")
print(f"Enter {lb}8{WHITE} {LIGHT_YELLOW}→{WHITE} Access Grade {YELLOW}8{WHITE}")
print(f"Enter {lb}9{WHITE} {LIGHT_YELLOW}→{WHITE} Access Grade {YELLOW}9{WHITE}")
print(f"Enter {lb}10{WHITE} {LIGHT_YELLOW}→{WHITE} Access Grade {YELLOW}10{WHITE}")
print(f"Enter {lb}11{WHITE} {LIGHT_YELLOW}→{WHITE} Access Grade {YELLOW}11{WHITE}")
print(f"Enter {lb}12{WHITE} {LIGHT_YELLOW}→{WHITE} Access Grade {YELLOW}12{WHITE}\n")
print(f"Enter {lb}13{WHITE} {LIGHT_YELLOW}→{WHITE} Change Password\n")
print(f"\n{RED}Any exceeding values will be clipped to the closest limit{WHITE}\n")
print(f"Type {YELLOW}QUIT{WHITE} to quit\n\n")
while True:
try:
listSelector = input(f"Enter your choice: {YELLOW}")
print(WHITE, end="")
if listSelector.lower() != "quit":
listSelector = int(listSelector)
if listSelector == 1:
ui("grade1.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector == 2:
ui("grade2.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector == 3:
ui("grade3.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector == 4:
ui("grade4.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector == 5:
ui("grade5.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector == 6:
ui("grade6.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector == 7:
ui("grade7.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector == 8:
ui("grade8.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector == 9:
ui("grade9.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector == 10:
ui("grade10.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector == 11:
ui("grade11.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector == 12:
ui("grade12.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector == 13:
updtPswrd()
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector < 1:
listSelector = 1
ui("grade1.json")
print(f"\n\n{'-'*70}\n\n")
system("cls")
elif listSelector > 13:
listSelector = 13
updtPswrd
print(f"\n\n{'-'*70}\n\n")
system("cls")
break
else:
iq = False
breakAll = True
break
except ValueError:
if not str(listSelector).strip():
print(f"{DEL_LINE}Enter your choice: {YELLOW}\033[3m*BLANK*\033[0m{WHITE}")
print("Invalid Input\n")
else:
print("Invalid Input\n")
if breakAll == True:
break
else:
print(f"{RED}Out of tries{WHITE}")
except Exception as e:
print(f"Error: {e}")
input("Press Enter to continue")