flag = b'Neepu{********************}' flag = bytes_to_long(flag) p = getPrime(512) q = getPrime(512) n = p*q e = nextprime(random.randint(1,1000)) d = gmpy2.invert(e, (p-1)*(q-1)) c = pow(flag, e, n) print(c) print(n)
m = encode(p, q, e) c1 = pow(m, 7, n) c2 = pow(m+e, 7, n) print(c1) print(c2)
from Crypto.Util.number import isPrime, long_to_bytes from gmpy2 import invert c1 = 10186066785511829759164194803209819172224966119227668638413350199662683285189286077736537161204019147791799351066849945954518642600518196927152098131117402608793752080104402893792812059620726950782670809837962606250674588612783027976958719051829085903720655233948024280118985875980227528403883475592567727892 c2 = 46182103994299145562022812023438495797686077104477472631494150222038404419414100727667171290098624214113241032861128455086601197239761085752413519627251290509474327611253599768650908336142621210005389246714504358370629231557080301516460985022782887233790302054696967900384601182742759555421864610431428746119 n = 91995272927105081122659192011056020468305570748555849650309966887236871318156855318666540461669669247866754568189179687694315627673545298267458869140096224628114424176937828378360997230874932015701507629238213240839370628366083111028544554453150572165461450371411341485911677167168492357154684642531577228543 c = 78543767285872349029076059073458316000847341792088805258173041942425687239313215276670106926320359777962661495032475004417723103701253550583245518206305422982968675291500865382213182669036827898932991063338163290845510339896689210314509493839746410486257998875782496654704288722251878269643040214139429715671 m_e = 129256555243625096140386916253259867206651269142565502540823654159666398099455456877012993395632742360829588042575108302297567291349420390228163587340930 m = 129256555243625096140386916253259867206651269142565502540823654159666398099455456877012993395632742360829588042575108302297567291349420390228163587340859 # e = m_e - m # print(e) e = 71 not_p = m p = 1 for i inrange(1, 1000): if (e*not_p-1) % i == 0and isPrime((e*not_p-1) // i - 1): p = (e*not_p-1) // i - 1 break
assert n % p == 0 q = n // p d = invert(e, (p-1)*(q-1)) print(long_to_bytes(pow(c, d, n)))