forked from hzhoanglee/PythonCarParking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login_verification.py
23 lines (19 loc) · 898 Bytes
/
login_verification.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from utils import IOdb
import bcrypt
class LoginVerification:
def __init__(self):
self.settings = IOdb.fetch_settings_db()
self.password = self.settings[4]['conf_value']
self.__hashed_password = self.hash_password_db()
# ==================================================================================================================
# hashing password from db
def hash_password_db(self):
return bcrypt.hashpw(self.password.encode('utf-8'), bcrypt.gensalt())
# ==================================================================================================================
def verify_password(self, password):
if bcrypt.checkpw(password.encode('utf-8'), self.__hashed_password):
print("Password is correct")
return True
else:
print("Password is incorrect")
return False