Bcrypt salting
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
DESKTOP-DPA61F8\Benedek 2021-04-29 20:09:37 +02:00
parent 6d2441d931
commit 18bfac4a86
2 changed files with 5 additions and 3 deletions

View File

@ -11,6 +11,7 @@ from Crypto.Hash import SHA256
from Crypto.Protocol.KDF import bcrypt, bcrypt_check
from Crypto.PublicKey import RSA
from Crypto.PublicKey.RSA import RsaKey
from Crypto.Random import get_random_bytes
auth_logger = logging.getLogger('AUTH APPLICATION ')
auth_logger.setLevel(logging.INFO)
@ -82,9 +83,10 @@ class Authetication:
def saveUser(self, username: str, password: str) -> bool:
user_salt = get_random_bytes(16)
bytePass = password.encode('utf-8')
b64pwd = b64encode(SHA256.new(bytePass).digest())
bcrypt_hash = bcrypt(b64pwd, 12)
bcrypt_hash = bcrypt(password=b64pwd, cost=12, salt=user_salt)
with open(self.CONFIG_FILE_LOCATION) as json_file:
data = json.load(json_file)

View File

@ -35,7 +35,7 @@ def testAuth(username: str, password: str):
auth.saveUser(username, password)
homeDir = auth.login(username, password)
if homeDir == '1':
if homeDir == auth.HOME_DIRECTORY_LOCATION + os.path.sep + '1':
test_logger.info('TEST 1 --> Authentication test with VALID :: PASSED')
else:
test_logger.info('TEST 1 --> Authentication test with VALID :: FAILED')
@ -118,4 +118,4 @@ if __name__ == '__main__':
testSaveUser("Diósbejglia", "Diósbejgli")
testAuth("Diósbejglia", "Diósbejgli")
testUserExists("Diósbejglia", "Diósbejgli")
testPersistency()
#testPersistency()