From 1924c14df0852548c473f7de1bf58866bd80f8e2 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sat, 18 Apr 2020 03:15:08 +0300 Subject: [PATCH] Fixed bugs: - Key save did not save all values. - Index out of range of tempKey when only it is only public part. Signed-off-by: HeshamTB --- rsa.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rsa.py b/rsa.py index 2b33dc0..02c97fc 100755 --- a/rsa.py +++ b/rsa.py @@ -177,8 +177,8 @@ def readKeyFile(keyName): key = tuple() with open(keysFolder+keyName, "r") as keyFile: tempkey = keyFile.readlines() - if len(tempkey) == 2: #means it only public part (n, e) - key = (int(tempkey[N].strip(), 16), int(tempkey[E].strip(), 16), 0, 0, 0, 0, tempkey[ID]) + if len(tempkey) == 3: #means it only public part (n, e, id) + key = (int(tempkey[N].strip(), 16), int(tempkey[E].strip(), 16), 0, 0, 0, 0, tempkey[2]) else: #Make this a loop from 0 to 5 key = (int(tempkey[N].strip(), 16), int(tempkey[E].strip(), 16), @@ -194,7 +194,7 @@ def saveKeyFile(key, fileName): if not os.path.isdir(keysFolder): os.makedirs(keysFolder) with open(keysFolder+fileName, "w") as keyFile: - for entry in range(0, 5): + for entry in range(0, 6): keyFile.write(hex(key[entry])+"\n") keyFile.write(key[ID]+"\n")