-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsign_in.py
55 lines (43 loc) · 1.09 KB
/
sign_in.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
def sign_in(username, password):
import sqlite3
import getpass
import hashlib
conn = sqlite3.connect('users_data.db')
curs = conn.cursor()
curs.execute('SELECT * FROM users')
rows = curs.fetchall()
users_list = []
pass_list = []
for i in rows:
users_list.append(i[1])
pass_list.append(i[2])
#print(users_list,pass_list)
#print(users_list.index('bittu'))
sign_in_flag = False
while True:
#username = input("Please enter your username : ")
username = str(username)
if username in users_list:
n = users_list.index(username)
testpass = pass_list[int(n)]
#p = getpass.getpass()
p = str(password)
phash = hashlib.sha256(p.encode('utf-8')).hexdigest()
if str(phash) == str(testpass):
print("\n")
print("Welcome ", username,'!')
print("Sign in processed successfully!")
sign_in_flag = True
break
else:
print(testpass,',',p)
print("You typed wrong password")
sign_in_flag = False
break
else:
print (
username,"Sorry no username have \
registered with this username")
break
sign_in_flag = False
return sign_in_flag