From 51d9571a3708122dc0ceb8212cbc2bd27b56d3c4 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 5 Jul 2020 10:08:51 +0300 Subject: [PATCH 1/5] Save message to file --- rsa.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rsa.py b/rsa.py index 78ecb14..a47574b 100755 --- a/rsa.py +++ b/rsa.py @@ -57,8 +57,10 @@ def main(): for word in msg_list: msg_encrypted = msg_encrypted + " " + hex(encrypt(word, key_public)) #msg_encrypted = encrypt(msg, key_public) + sighned_msg = sign(msg_encrypted, signing_key) print("Encrypted msg: \n", msg_encrypted) - print("Signed: \n", sign(msg_encrypted, signing_key)) ## Adds an encrypted sig at the end of message. + print("Signed: \n", sighned_msg) ## Adds an encrypted sig at the end of message. + saveToFile(sighned_msg, "encrypted-msg.txt") else: print("Not enough arguments") print("rsa encrypt ") @@ -278,6 +280,11 @@ def exportKey(keyFileName): saveKeyFile(public_key, key[ID]+"-public") print("Saved public form of key {} in keys folder".format(key[ID])) +def saveToFile(msg, file): + msg = str(msg) + with open(file,"w") as msg_file: + msg_file.write(msg) + def crackKey(keyName): print("in crack") key = readKeyFile(keyName) -- 2.39.5 From 960468ad214f0b182b57090d28f687ea46854da4 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 6 Jul 2020 00:29:30 +0300 Subject: [PATCH 2/5] Output header/footer --- rsa.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rsa.py b/rsa.py index a47574b..c96f5d3 100755 --- a/rsa.py +++ b/rsa.py @@ -24,6 +24,8 @@ P=3 Q=4 PHI=5 ID=6 +FILE_HEADER = "---------- START OF RSA ENCRYPTED MESSAGE ----------" +FILE_FOOTER = "---------- END OF RSA ENCRYPTED MESSAGE ----------" def main(): @@ -283,7 +285,10 @@ def exportKey(keyFileName): def saveToFile(msg, file): msg = str(msg) with open(file,"w") as msg_file: - msg_file.write(msg) + msg_file.writelines(FILE_HEADER + "\n") + msg_file.writelines(msg + "\n") + msg_file.writelines(FILE_FOOTER + "\n") + def crackKey(keyName): print("in crack") -- 2.39.5 From d7a8ec02ea6c69dddc2d06484ac5cda6f14c76b5 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 6 Jul 2020 02:16:10 +0300 Subject: [PATCH 3/5] Rename rsa.py to hrsa: hashbang in hrsa file will invoke python3 on linux --- rsa.py => hrsa | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename rsa.py => hrsa (100%) diff --git a/rsa.py b/hrsa similarity index 100% rename from rsa.py rename to hrsa -- 2.39.5 From 7bfe4c3c89c1b75bf9609b0997ce26968331cf28 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 24 Jul 2020 10:49:45 +0300 Subject: [PATCH 4/5] Ignore new ecnrypted msg files. Signed-off-by: HeshamTB --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 542eed8..1e72366 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__/ keys/ test-file +encrypted*.txt -- 2.39.5 From 96e8f753ff3e1cd3e8b7baccb2e674fb70d8c0cb Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 28 Aug 2020 19:26:06 +0300 Subject: [PATCH 5/5] prepare merge --- .gitignore | 1 - hrsa => rsa.py | 0 2 files changed, 1 deletion(-) rename hrsa => rsa.py (100%) diff --git a/.gitignore b/.gitignore index 1e72366..542eed8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ __pycache__/ keys/ test-file -encrypted*.txt diff --git a/hrsa b/rsa.py similarity index 100% rename from hrsa rename to rsa.py -- 2.39.5