Improved output:

- Print tested numbers as lines instead of
	using \r.
	- List command add more space for key name

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2022-10-19 18:08:35 +03:00
parent 6d9e071aa4
commit ec2bbf116b
Signed by: Hesham
GPG Key ID: 74876157D199B09E

4
rsa.py Normal file → Executable file
View File

@ -188,7 +188,7 @@ def getPrime(bits):
while True: while True:
#Byte order "little" or "big" does not matter here since we want a random number from os.urandom() #Byte order "little" or "big" does not matter here since we want a random number from os.urandom()
x = int.from_bytes(os.urandom(int(bits/8)), byteOrder) x = int.from_bytes(os.urandom(int(bits/8)), byteOrder)
print(x, end="") print('Trying: ', x, end="\n")
if mr.is_prime(x): if mr.is_prime(x):
print("\nprime: ", x) print("\nprime: ", x)
return x return x
@ -325,7 +325,7 @@ def listKeys():
if key[D] == 0: if key[D] == 0:
check = "".strip() check = "".strip()
else: check = '\u2713' else: check = '\u2713'
print("%7s%7s%7s-bit" % (key[ID].strip(), check, key[N].bit_length())) print("%10s%7s%7s-bit" % (key[ID].strip(), check, key[N].bit_length()))
def exportKey(keyFileName): def exportKey(keyFileName):
key = readKeyFile(keyFileName) key = readKeyFile(keyFileName)