Created
October 20, 2015 02:41
-
-
Save dendisuhubdy/a821728833b05bc6ea48 to your computer and use it in GitHub Desktop.
Cracking the RSA cyprtosystem time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gmpy, time, random, math | |
def genprime(bits): | |
p=1 | |
while(gmpy.is_prime(p)==0): | |
p = random.randrange(math.pow(2,bits-1),math.pow(2,bits)) | |
return p | |
BITS=20 | |
found=False | |
p=genprime(BITS) | |
q=genprime(BITS) | |
n=p*q | |
cnt=2 | |
s_time=time.time() | |
while not found: | |
found=(n%cnt==0) | |
cnt+=1 | |
e_time=time.time()-s_time | |
if found: | |
print "%d can be devided by %d"%(n, cnt-1) | |
print "It took %d ms "%(cnt-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment