Fixed output of listKeys().
Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
bfc572386e
commit
45c1abd0fa
8
rsa.py
8
rsa.py
@ -101,7 +101,7 @@ def generateKeys(id, bits=64):
|
|||||||
#e exponant should be 1 < e < lamda(n) and GCD(e, lamda(n)) = 1 (coprime)
|
#e exponant should be 1 < e < lamda(n) and GCD(e, lamda(n)) = 1 (coprime)
|
||||||
# recommended value is 65,537
|
# recommended value is 65,537
|
||||||
e = 65537
|
e = 65537
|
||||||
d = pow(e,-1,phi)
|
d = pow(e,-1,phi) # d = e^-1 mod phi
|
||||||
return (n, e, d, p, q, phi, id)
|
return (n, e, d, p, q, phi, id)
|
||||||
|
|
||||||
def encrypt(message, publicKey):
|
def encrypt(message, publicKey):
|
||||||
@ -226,16 +226,16 @@ def listKeys():
|
|||||||
if not os.path.isdir(keysFolder):
|
if not os.path.isdir(keysFolder):
|
||||||
os.makedirs(keysFolder)
|
os.makedirs(keysFolder)
|
||||||
local_keys = os.listdir(keysFolder)
|
local_keys = os.listdir(keysFolder)
|
||||||
print(local_keys)
|
|
||||||
if len(local_keys) == 0:
|
if len(local_keys) == 0:
|
||||||
|
print("Cant find local keys.")
|
||||||
return
|
return
|
||||||
print("ID PRIVATE")
|
print("ID PRIVATE")
|
||||||
print("________________")
|
print("________________")
|
||||||
for keyName in local_keys:
|
for keyName in local_keys:
|
||||||
key = readKeyFile(keyName)
|
key = readKeyFile(keyName)
|
||||||
if key[D] == 0:
|
if key[D] == 0:
|
||||||
check = u''
|
check = "".strip()
|
||||||
else: check = u'\u2713'
|
else: check = '\u2713'
|
||||||
print("{} {}\n".format(key[ID], check))
|
print("{} {}\n".format(key[ID], check))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user