import random
import gmpy2

e = 0x10001
p = 0
q = 0
file = 'c:/Users/waltba04/Downloads/flag.txt' # Contains SKY-TEST-1234

while not gmpy2.is_prime(p) or not gmpy2.is_prime(q) or (p-1) % e == 0 or (q-1) % e == 0: # This only loops if p/q is invalid
    p = random.getrandbits(512)
    # q = int(gmpy2.digits(p, 2))
    q = int(gmpy2.digits(p, 2)) # q is actually equal to p
    

n = p * q # Because p and q are equal, this is equivalent to p^2

with open(file, 'rb') as f:
    m = f.read()
    m = int.from_bytes(m, 'big') # Evaluates to 6599256672879500262705451905844 for this example
    print(f'{m = }')

c = pow(m, e, n)

print(f'{n = }')
print(f'{e = }')
print(f'{c = }')

"""
Example Variable Values:

p = 9853753452018776515387531243176796842927785995955096350371873339908081354784386747476421491414405133202457323391529275244245507116217291973850692284889569

int(str(q),2) = 9853753452018776515387531243176796842927785995955096350371873339908081354784386747476421491414405133202457323391529275244245507116217291973850692284889569

m = 6599256672879500262705451905844
n = 99632286538570658528841842890794603539714566221095397975867781542013866201096916579728422557087156402877345646963404400199162671626255621162011112794501886767906536288915097410585246210451972407132610228284467259979784193406616825994978332644340627016460239495687377536575596066337463215601501474087481135972900525591682397332605222015650876750081101572559945316187007494488738246357766939239874063669214339750154387837361518474157180808098763671394470527681214616837677644550409395711025409585963273575898385890333341576328546007675374913203558870425705850311054883826300398478152602848420621322689637704484455937032443976561308295079579042896824729917823400789569
e = 65537
c = 93480536822248760573026904534504012259025533417089540393661082088227944929703232617996803819957263940197111188392281014353108548900500511759943780194782477066615146408378347896649929042797221444694213198368379409922011195344371108796595715201132887040975012777171640644663442441172269839371929649307894775274583883675811246560875409882248201161550848471099451977510492860637515757923019786837994072405265867803376849184677636603842610819960556646902151609621356590871748732334506308127579623441685240962475903347616661726992250103199840686502225056280594630074424459307387503605782928866010164335722670425703475200471165870686569258879486129991251781533840357023308
"""