Skip to content

Instantly share code, notes, and snippets.

@mpentler
Last active April 21, 2019 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpentler/ce437f0c03a2439411a09d920e08ffac to your computer and use it in GitHub Desktop.
Save mpentler/ce437f0c03a2439411a09d920e08ffac to your computer and use it in GitHub Desktop.
c = 33313552017317510057480429807191513781560058913982045828821573360115041698572293368677814047055248844068758060891046601601923786757545000748868407887139102932189242384290168374262947094252294487798373472224578486694039636927104808579329053474121672431941292997540298195365595309282858493105333766871550453
n = 112844860286954432023527367807878149508433045460166798540067347297771292932276845482784411114349669858383468974822784047292525847593138653258906565706208925369627344743018629414710772644379028885399261868138745339538284054287450499199325709844121836918861140479086394315063831615503697572215910036672241273
e = 65537
primes = (2267190209, # obtain from factordb.com
2397761813,
2536127557,
2634219361,
2652518087,
2677343507,
2678478181,
2706190559,
2986792241,
2991035339,
3023199889,
3065683043,
3292834289,
3380613463,
3444111883,
3502639783,
3782148673,
3892239443,
3893697589,
3910722583,
3973506773,
3996896437,
4038234847,
4039850047,
4078487333,
4093567657,
4169967929,
4177820323,
4195305971,
4206931271,
4251966349,
4282363643)
def egcd(a, b):
if a == 0:
return (b, 0, 1)
g, y, x = egcd(b%a,a)
return (g, x - (b//a) * y, y)
def modinv(a, m):
g, x, y = egcd(a, m)
if g != 1:
raise Exception('No modular inverse')
return x%m
phi = 1
for prime in primes:
phi *= (prime-1)
d = modinv(e, phi)
plain = str(hex(pow(c, d, n)))[2::]
print plain[:-1].decode("hex")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment