Added a second thread. Should be faster. up to 140 bits
This commit is contained in:
parent
936a6eebb6
commit
18df4d2b07
10
rsa.py
10
rsa.py
@ -3,6 +3,8 @@
|
|||||||
#program to generate rsa key pair using methods in EE-305
|
#program to generate rsa key pair using methods in EE-305
|
||||||
# Hesham Banafa
|
# Hesham Banafa
|
||||||
|
|
||||||
|
#Large Prime check: https://www.alpertron.com.ar/ECM.HTM
|
||||||
|
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -44,10 +46,14 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
def generateKeys(bits=64):
|
def generateKeys(bits=64):
|
||||||
|
from multiprocessing.pool import Pool
|
||||||
#Primes of size 32 bit random
|
#Primes of size 32 bit random
|
||||||
#resulting in a 64-bit key mod
|
#resulting in a 64-bit key mod
|
||||||
p = getPrime(int(bits/2))
|
pool = Pool()
|
||||||
q = getPrime(int(bits/2))
|
result1 = pool.apply_async(getPrime, [int(bits/2)])
|
||||||
|
result2 = pool.apply_async(getPrime, [int(bits/2)])
|
||||||
|
p = result1.get()
|
||||||
|
q = result2.get()
|
||||||
n = p*q
|
n = p*q
|
||||||
#print("n: ", n)
|
#print("n: ", n)
|
||||||
print("%d bit key" % n.bit_length())
|
print("%d bit key" % n.bit_length())
|
||||||
|
Loading…
Reference in New Issue
Block a user