makes decrypt return text or write into file
This commit is contained in:
parent
e537f9087a
commit
25b8edae4a
|
@ -107,14 +107,17 @@ def decrypt_hybrid(private_key, encrypted_data):
|
||||||
|
|
||||||
|
|
||||||
# main function to decrypt the file
|
# 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:
|
with open(encrypted_file, 'rb') as f:
|
||||||
encrypted_content = f.read()
|
encrypted_content = f.read()
|
||||||
|
|
||||||
decrypted_content = decrypt_hybrid(private_key, encrypted_content)
|
decrypted_content = decrypt_hybrid(private_key, encrypted_content)
|
||||||
|
|
||||||
with open(decrypted_file, 'wb') as f:
|
if decrypted_file is None:
|
||||||
f.write(decrypted_content)
|
return decrypted_content
|
||||||
|
else:
|
||||||
|
with open(decrypted_file, 'wb') as f:
|
||||||
|
f.write(decrypted_content)
|
||||||
|
|
||||||
|
|
||||||
# function to load a private key from a file
|
# function to load a private key from a file
|
||||||
|
|
Loading…
Reference in New Issue