makes decrypt return text or write into file

This commit is contained in:
RubenCGomes 2024-11-19 20:29:00 +00:00
parent e537f9087a
commit 25b8edae4a
1 changed files with 6 additions and 3 deletions

View File

@ -107,12 +107,15 @@ def decrypt_hybrid(private_key, encrypted_data):
# main function to decrypt the file
def decrypt_file(private_key, encrypted_file, decrypted_file):
def decrypt_file(private_key, encrypted_file, decrypted_file=None):
with open(encrypted_file, 'rb') as f:
encrypted_content = f.read()
decrypted_content = decrypt_hybrid(private_key, encrypted_content)
if decrypted_file is None:
return decrypted_content
else:
with open(decrypted_file, 'wb') as f:
f.write(decrypted_content)