Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ashutosh1206
GitHub Repository: ashutosh1206/crypton
Path: blob/master/RSA-encryption/Factorisation-Pollard's_p-1/exploit.py
1402 views
1
from sage.all import *
2
3
def pollard(n, B):
4
a = 2
5
for p in primes(B):
6
pp = 1
7
while pp*p <= B:
8
pp *= p
9
a = pow(a, pp, n) # provided a>=b, gcd(a, b) = gcd(a%b, b)
10
g = gcd(a-1, n)
11
if 1 < g < n:
12
return g
13
return None
14