crypto/mind_your_ps_and_qs
This commit is contained in:
parent
095786747a
commit
ed63e69062
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i sage -p sage
|
||||
|
||||
from sage.all import *
|
||||
import time
|
||||
import sys
|
||||
|
||||
c = 8533139361076999596208540806559574687666062896040360148742851107661304651861689
|
||||
n = 769457290801263793712740792519696786147248001937382943813345728685422050738403253
|
||||
e = 65537
|
||||
|
||||
if len(sys.argv) >= 2 and sys.argv[1] == 'CACHE':
|
||||
print('Using precalculated p & q')
|
||||
p = 1617549722683965197900599011412144490161
|
||||
q = 475693130177488446807040098678772442581573
|
||||
else:
|
||||
print('Factorizing N')
|
||||
# Takes about 7-8 minutes on my own pc
|
||||
start = time.time()
|
||||
factorization = ZZ(n).factor(algorithm='qsieve')
|
||||
stop = time.time()
|
||||
print(f"Took: {stop - start}")
|
||||
|
||||
p, q = [x[0] for x in list(factorization)]
|
||||
|
||||
phi = (p - 1) * (q - 1)
|
||||
d = inverse_mod(e, phi)
|
||||
m = power_mod(c, d, n)
|
||||
|
||||
print(m.to_bytes((m.bit_length() + 7) // 8, 'big').decode())
|
|
@ -0,0 +1,4 @@
|
|||
Decrypt my super sick RSA:
|
||||
c: 8533139361076999596208540806559574687666062896040360148742851107661304651861689
|
||||
n: 769457290801263793712740792519696786147248001937382943813345728685422050738403253
|
||||
e: 65537
|
Loading…
Reference in New Issue