Skip to content

Instantly share code, notes, and snippets.

@GordonOus
Created August 23, 2021 12:02
Show Gist options
  • Save GordonOus/cc1f3eced2b996bf15893ee2ef3d2431 to your computer and use it in GitHub Desktop.
Save GordonOus/cc1f3eced2b996bf15893ee2ef3d2431 to your computer and use it in GitHub Desktop.
import gmpy2
from Crypto.Util.number import long_to_bytes, bytes_to_long
from binascii import unhexlify
flag = open('output.txt','r').read().strip().split(' ')[1]
ciphertext = bytes_to_long(flag)
e = 3
#Fist method of getting cube root of ciphertext
gmpy2.get_context().precision = 4096
m = long_to_bytes(round(gmpy2.root(ct,e))).decode()
#second method of using the log to base10: 10 ** log(ct)/e
m2 = long_to_bytes(pow(10,gmpy2.log10(ct)/e))
print(f'{m}\n{m2}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment