From 998089f94c01e9642cc3ec81d96f3bc9278eda41 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sat, 18 Apr 2020 03:27:08 +0300 Subject: [PATCH] Added list keys command. Signed-off-by: HeshamTB --- rsa.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/rsa.py b/rsa.py index 3337388..07a4cfa 100755 --- a/rsa.py +++ b/rsa.py @@ -66,7 +66,8 @@ def main(): # cipher = int(cipherFile.readline()) ##one line may make problems later with padding print("Signed by: ", sig) print("Decrypted message: \n", msg_decrypted) - + if sys.argv[1] == "list": + listKeys() @@ -214,5 +215,22 @@ def printKey(key): "\n----------------------------------------------", ) +def listKeys(): + if not os.path.isdir(keysFolder): + os.makedirs(keysFolder) + local_keys = os.listdir(keysFolder) + print(local_keys) + if len(local_keys) == 0: + return + print("ID PRIVATE") + print("________________") + for keyName in local_keys: + key = readKeyFile(keyName) + if key[D] == 0: + check = u'' + else: check = u'\u2713' + print("{} {}\n".format(key[ID], check)) + + if __name__ == "__main__": main() \ No newline at end of file