Added list keys command.

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2020-04-18 03:27:08 +03:00
parent d1257320a8
commit 998089f94c
Signed by: Hesham
GPG Key ID: 74876157D199B09E

20
rsa.py
View File

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