From 4e5dc7485e808aaf981c0107a5c93bd8271b6744 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Sun, 1 Mar 2020 20:46:43 +0300 Subject: [PATCH] #SafeSource Create tested # Run in prototype --- Sources/pyOpenRPA/Tools/SafeSource/Crypter.py | 22 ++++++- .../pyOpenRPA/Tools/SafeSource/DistrCreate.py | 58 ++++++++++++++----- .../pyOpenRPA/Tools/SafeSource/DistrRun.py | 44 +++++++------- .../pyOpenRPA/Tools/SafeSource/__main__.py | 2 +- 4 files changed, 87 insertions(+), 39 deletions(-) diff --git a/Sources/pyOpenRPA/Tools/SafeSource/Crypter.py b/Sources/pyOpenRPA/Tools/SafeSource/Crypter.py index 62705ef2..6a44c717 100644 --- a/Sources/pyOpenRPA/Tools/SafeSource/Crypter.py +++ b/Sources/pyOpenRPA/Tools/SafeSource/Crypter.py @@ -34,7 +34,6 @@ def encrypt_file(key, in_filename, out_filename=None, chunksize=64*1024): outfile.write(iv) while True: chunk = infile.read(chunksize) - print(chunk) if len(chunk) == 0: break elif len(chunk) % 16 != 0: @@ -61,4 +60,23 @@ def decrypt_file(key, in_filename, out_filename=None, chunksize=24*1024): if len(chunk) == 0: break outfile.write(decryptor.decrypt(chunk)) - outfile.truncate(origsize) \ No newline at end of file + outfile.truncate(origsize) +def decrypt_file_bytes(key, in_filename, chunksize=24*1024): + """ Расшифровывает файл, используя AES (режим CBC) с + заданным ключом. + """ + lResult = b'' + if not out_filename: + out_filename = os.path.splitext(in_filename)[0] + with open(in_filename, 'rb') as infile: + origsize = struct.unpack('