figenc

[RADIOACTIVE] rsa and symmetric key encryption scripts and executables
git clone git://git.figbert.com/figenc.git
Log | Files | Refs | README

commit 36f1bc9aeb300f52dc2fd35521a2424dc6b118bb
parent e4b348e1778b5d50db7acffcbfd17f9c02928d10
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Sat, 10 Aug 2019 15:04:54 -0700

2.2.0

Diffstat:
MScripts/encrypt.py | 9++++++---
MScripts/version.txt | 4++--
2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Scripts/encrypt.py b/Scripts/encrypt.py @@ -15,15 +15,18 @@ def RSA(target_file, public_key_source): target_file -- the filepath to the file to be encrypted public_key_source -- the filepath to the public key """ - with open(public_key_source, "rb") as public_key_file, \ - open(target_file) as read_file: + with open(public_key_source, "rb") as public_key_file: public_key = serialization.load_pem_public_key( public_key_file.read(), backend=default_backend() ) + try: + with open(target_file) as read_file: file_data = read_file.read() - if not isinstance(file_data, bytes): file_data = bytes(file_data, "utf-8") + except UnicodeDecodeError: + with open(target_file, "rb") as read_file: + file_data = read_file.read() data = public_key.encrypt( file_data, padding.OAEP( diff --git a/Scripts/version.txt b/Scripts/version.txt @@ -1 +1 @@ -2.1.9 -\ No newline at end of file +2.2.0 +\ No newline at end of file