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

This commit is contained in:
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)