From 3cb86f17f24b127aef7c0f6e33f2fc683a918946 Mon Sep 17 00:00:00 2001 From: RubenCGomes Date: Wed, 18 Dec 2024 00:12:43 +0000 Subject: [PATCH] fix in decryption, changed its test to have consistent result (thanks /dev/zero) --- delivery2/client/bin/rep_decrypt_file | 9 +++++++-- delivery2/client/tests/test_client.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/delivery2/client/bin/rep_decrypt_file b/delivery2/client/bin/rep_decrypt_file index 6adff75..7516f60 100755 --- a/delivery2/client/bin/rep_decrypt_file +++ b/delivery2/client/bin/rep_decrypt_file @@ -39,10 +39,15 @@ def decryptFile(args): # sys.exit(1) #Decrypt file - print(args.metadata) + # print(args.metadata) metadata = json.loads(args.metadata) - content = symmetric_encryption.decrypt_file(metadata['key'].encode(), BASE_DIR + args.encrypted) + print(BASE_DIR + args.encrypted) + + content = symmetric_encryption.decrypt_file(bytes.fromhex(metadata['key']), BASE_DIR + args.encrypted) + + with open(BASE_DIR + 'decryped_file.txt', 'w') as f: + f.write(content) # Send decrypted content to stdout sys.stdout.write(content) diff --git a/delivery2/client/tests/test_client.py b/delivery2/client/tests/test_client.py index 48d1dd6..8cc5b42 100644 --- a/delivery2/client/tests/test_client.py +++ b/delivery2/client/tests/test_client.py @@ -85,7 +85,7 @@ def test_rep_activate_subject(): def test_rep_add_doc(): # Test the rep_add_doc command - process = subprocess.Popen(f"dd if=/dev/urandom of={FILES_PATH}test.txt bs=1024 count=1000 ", shell=True) + process = subprocess.Popen(f"dd if=/dev/zero of={FILES_PATH}test.txt bs=1024 count=1000 ", shell=True) process.wait() assert process.returncode == 0