encoding and decoding result of fernet to store data better
This commit is contained in:
parent
63de9010de
commit
2ea3096fb0
@ -27,8 +27,8 @@ def encrypt_account_info(
|
|||||||
salt = os.urandom(64)
|
salt = os.urandom(64)
|
||||||
key = _generate_key(salt, master_pass.encode("utf-8"))
|
key = _generate_key(salt, master_pass.encode("utf-8"))
|
||||||
f = Fernet(key)
|
f = Fernet(key)
|
||||||
enc_login = f.encrypt(login.encode("utf-8"))
|
enc_login = base64.urlsafe_b64decode(f.encrypt(login.encode("utf-8")))
|
||||||
enc_passwd = f.encrypt(passwd.encode("utf-8"))
|
enc_passwd = base64.urlsafe_b64decode(f.encrypt(passwd.encode("utf-8")))
|
||||||
return (enc_login, enc_passwd, salt)
|
return (enc_login, enc_passwd, salt)
|
||||||
|
|
||||||
|
|
||||||
@ -39,6 +39,6 @@ def decrypt_account_info(
|
|||||||
Returns a tuple of decrypted login and password"""
|
Returns a tuple of decrypted login and password"""
|
||||||
key = _generate_key(salt, master_pass.encode("utf-8"))
|
key = _generate_key(salt, master_pass.encode("utf-8"))
|
||||||
f = Fernet(key)
|
f = Fernet(key)
|
||||||
login_bytes = f.decrypt(enc_login)
|
login_bytes = f.decrypt(base64.urlsafe_b64encode(enc_login)).decode("utf-8")
|
||||||
pass_bytes = f.decrypt(enc_pass)
|
pass_bytes = f.decrypt(base64.urlsafe_b64encode(enc_pass)).decode("utf-8")
|
||||||
return (login_bytes.decode("utf-8"), pass_bytes.decode("utf-8"))
|
return (login_bytes, pass_bytes)
|
||||||
|
Reference in New Issue
Block a user