fix in decryption, changed its test to have consistent result (thanks /dev/zero)

This commit is contained in:
RubenCGomes 2024-12-18 00:12:43 +00:00
parent 75ac6cd045
commit 3cb86f17f2
No known key found for this signature in database
2 changed files with 8 additions and 3 deletions

View 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)

View File

@ -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