Skip to content

Commit

Permalink
Hopefully ai overlord will be happy with this commit!
Browse files Browse the repository at this point in the history
  • Loading branch information
lunamidori5 committed Nov 16, 2024
1 parent 0c03832 commit 6ca4386
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Webserver/Programs/File_manager/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def encrypt_user_data(data: bytes, username: str, salt):
hash_hex = hash_object.hexdigest()

# Generate a 32-byte Fernet-compatible key
key = base64.urlsafe_b64encode(hashlib.sha256(hash_hex.encode() + salt).digest())
key = base64.urlsafe_b64encode(hashlib.sha512(hash_hex.encode() + salt).digest())

cipher = Fernet(key)
encrypted_data = cipher.encrypt(data)
Expand Down Expand Up @@ -149,7 +149,7 @@ def decrypt_user_data(encrypted_data: bytes, username: str, salt):
hash_hex = hash_object.hexdigest()

# Generate the same 32-byte Fernet-compatible key for decryption
key = base64.urlsafe_b64encode(hashlib.sha256(hash_hex.encode() + salt).digest())
key = base64.urlsafe_b64encode(hashlib.sha512(hash_hex.encode() + salt).digest())
cipher = Fernet(key)

decrypted_data = cipher.decrypt(encrypted_data).decode()
Expand Down

0 comments on commit 6ca4386

Please sign in to comment.