Better output while finding primes:

use \b instead of \r with the count of digits of tested number.
	still outputs a mess at start due to multithreads output at same time,
	however, stable after first itiration.
This commit is contained in:
HeshamTB 2020-09-06 06:13:19 +03:00
parent ea5a9195be
commit a36de9cf67
Signed by: Hesham
GPG Key ID: 74876157D199B09E

11
rsa.py
View File

@ -165,11 +165,11 @@ def getPrime(bits):
while True:
#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)
print("trying: ", x, end="")
print(x, end="")
if mr.is_prime(x):
print("\nprime: ", x)
return x
print("\r",end="")
backTrack(x)
def isPrime(number):
@ -339,5 +339,12 @@ def printHelp():
print("rsa print <key>")
print("rsa list")
def backTrack(x):
#Back track and clear terminal with length of x
length = len(str(x))
while length > 0:
print("\b",end="")
length -= 1
if __name__ == "__main__":
main()