From b94060ef1fa07cb072593f7085b8cd0be5874dca Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 20 Oct 2020 22:55:38 +0300 Subject: Update how pbkdf2.pbkdf2_hex is used when encrypting pass * wqflask/wqflask/user_login.py (encode_password): - Remove unused local variable "salt". - Pass "hashfunc" as a string. - Apply Pep-8. --- wqflask/wqflask/user_login.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/user_login.py b/wqflask/wqflask/user_login.py index cb2edbc5..f25ebc32 100644 --- a/wqflask/wqflask/user_login.py +++ b/wqflask/wqflask/user_login.py @@ -37,15 +37,13 @@ def basic_info(): ip_address = request.remote_addr, user_agent = request.headers.get('User-Agent')) -def encode_password(pass_gen_fields, unencrypted_password): - hashfunc = getattr(hashlib, pass_gen_fields['hashfunc']) - salt = base64.b64decode(pass_gen_fields['salt']) +def encode_password(pass_gen_fields, unencrypted_password): encrypted_password = pbkdf2.pbkdf2_hex(str(unencrypted_password), - pass_gen_fields['salt'], - pass_gen_fields['iterations'], - pass_gen_fields['keylength'], - hashfunc) + pass_gen_fields['salt'], + pass_gen_fields['iterations'], + pass_gen_fields['keylength'], + pass_gen_fields['hashfunc']) pass_gen_fields.pop("unencrypted_password", None) pass_gen_fields["password"] = encrypted_password -- cgit v1.2.3