Merge pull request 'term-output' (#4) from term-output into master
Reviewed-on: https://apollo-server.ddns.net/gitea/Hesham/hesham-rsa/pulls/4
This commit is contained in:
commit
f5eef6a226
13
rsa.py
13
rsa.py
@ -28,7 +28,7 @@ ID=6
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("hesham-rsa version ", VERSION)
|
print("hesham-rsa version ", VERSION)
|
||||||
if sys.argv[1] == "gen": ##rsa gen <keysize> <keyname>
|
if sys.argv[1] == "gen" and len(sys.argv) == 4: ##rsa gen <keysize> <keyname>
|
||||||
keyFileName = sys.argv[3]
|
keyFileName = sys.argv[3]
|
||||||
key = generateKeys(keyFileName, int(sys.argv[2]))
|
key = generateKeys(keyFileName, int(sys.argv[2]))
|
||||||
print("e: ", key[E])
|
print("e: ", key[E])
|
||||||
@ -170,11 +170,11 @@ 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("trying: ", x, end="")
|
print(x, end="")
|
||||||
if mr.is_prime(x):
|
if mr.is_prime(x):
|
||||||
print("\nprime: ", x)
|
print("\nprime: ", x)
|
||||||
return x
|
return x
|
||||||
print("\r",end="")
|
backTrack(x)
|
||||||
|
|
||||||
|
|
||||||
def isPrime(number):
|
def isPrime(number):
|
||||||
@ -344,5 +344,12 @@ def printHelp():
|
|||||||
print("rsa print <key>")
|
print("rsa print <key>")
|
||||||
print("rsa list")
|
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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user