From 18df4d2b07134017fafe393634942a1d5e92a808 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 17 Apr 2020 12:23:08 +0300 Subject: [PATCH] Added a second thread. Should be faster. up to 140 bits --- rsa.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rsa.py b/rsa.py index b9e6a8d..caa4638 100755 --- a/rsa.py +++ b/rsa.py @@ -3,6 +3,8 @@ #program to generate rsa key pair using methods in EE-305 # Hesham Banafa +#Large Prime check: https://www.alpertron.com.ar/ECM.HTM + import math import os import sys @@ -44,10 +46,14 @@ def main(): def generateKeys(bits=64): + from multiprocessing.pool import Pool #Primes of size 32 bit random #resulting in a 64-bit key mod - p = getPrime(int(bits/2)) - q = getPrime(int(bits/2)) + pool = Pool() + 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 #print("n: ", n) print("%d bit key" % n.bit_length())