Skip to content

Instantly share code, notes, and snippets.

@samueltangz
Created November 27, 2018 09:08
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 samueltangz/819e0a664b5537138dec92e2c9c45a3c to your computer and use it in GitHub Desktop.
Save samueltangz/819e0a664b5537138dec92e2c9c45a3c to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import gmpy
from Crypto.Util.number import *
from secret import x, y, flag
assert gmpy.is_prime(y)
assert gmpy.is_prime(x+1)
assert (x**2 - 1)**2 % (4*x*y - 1) == 0
p = gmpy.next_prime(x**5 + y**5)
q = gmpy.next_prime(x**2*y**3 + y**2*x**3)
n = p * q
enc = pow(bytes_to_long(flag), 0x10001, n)
print 'n =', n
print 'enc =', enc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment