baby Modular Technology
this one might be a little mathsy
Challenge script:
from Crypto.Util.number import getPrime
SECRET_MESSAGE = b"This is a fake message. You need to use the output in order to recover the real message. Anyway, here's some junk so that the message is of appropriate length. enigmatics is so cool! I love enigmatics."
assert len(SECRET_MESSAGE) == 201
def bytes_to_long(byte_string):
return int(byte_string.hex(), 16)
def long_to_bytes(integer):
return bytes.fromhex(hex(integer)[2:])
p, q = getPrime(1024), getPrime(1024) # generate two large primes
modulus = p * q # multiply them together
exponent = 1
print(modulus)
print((bytes_to_long(SECRET_MESSAGE) ** exponent) % modulus) # encrypt using RSA, by doing pt raised to the power of exponent (3) modulo the modulus
Output:
17845097488596639845518134386175507154138020633028978410599492028517185249762037941921834310735343524416248353253297004195034415311652348836343210124772724156933556474501204108447031043065370143020118340841009308082569275068337588680708705817539633555913471436360805549182752511044555690261882864681449364372080830664440708636199339903319195562063527895839659283871512345578702252921421500462837606285164842704956629612659250186753272777602890359528736658773682337895707675287899998993856744285265279750099474752160466960081514750255995189850248416415689506400427175761412047149724013540570133933037768024101486378921
4464546116043465080725086728135721186421551998994298185795184113369194141931808356261973191771603232472347856620304536340486415244048057136394402648172582167263525763507999892546695785155389836019857067059329844145393639738027314536187312344281320972310479504663255912873389143515679290355306708678056818192416702976443834017292358856475472481820752295754775314065426809062967610934573792037574956623980674960412246584165785102773939556164134182466021463864399364067784086516913366386
note: dcode.fr can be used to deal with any large number operations