-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheAuth.py
42 lines (35 loc) · 1.36 KB
/
eAuth.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
# imports
import pickle, caesarCipher, csv
import election
#---------------------------------------------------------Logins----------------------------------------------------------
def adminLogin(): #Admin login details check
print("")
print("Log in as administrator")
adminName = input("Admin Name: ")
adminPassword = input("Password: ")
f = open("Data/cred.dat", "rb")
try:
while True:
data = pickle.load(f)
if adminName == caesarCipher.caesarDecrypt(data['Admin Name']) and adminPassword == caesarCipher.caesarDecrypt(data["Password"]):
f.close()
return (True,adminName)
except EOFError:
f.close()
return (False,)
def voterLogin(): #Checks whether the VOTER'S name and UID exists within the database and correspond to each other
print("")
print("Log in as voter")
ID = input("ID: ")
name = input("Name: ")
if ID == "EXIT" or name == "EXIT":
return "EXIT"
f = open("Data/voterList.csv", 'r', newline="")
reader = csv.reader(f)
for i in reader:
if ID == i[0] and name == i[1] and election.hasVoted(ID) == False:
f.close()
return True
f.close()
return False
#^-------------------------------------------------------^Logins^--------------------------------------------------------^