Modular Technology


this one might be a little mathsy

intro puzzle

Challenge script:
from Crypto.Util.number import getPrime

SECRET_MESSAGE = b"This is a fake message. You need to use the output to recover the real message."
assert len(SECRET_MESSAGE) == 79

def to_bytes(x): # converts number to 256 bytes (base 10 -> base256)
    return x.to_bytes(256, "big")

def from_bytes(x): # converts 256 bytes to number (base256 -> base 10)
    return int.from_bytes(x, "big")

p, q = getPrime(1024), getPrime(1024) # generate two large primes
modulus = p * q # multiply them together
exponent = 3
print(modulus)
print((from_bytes(SECRET_MESSAGE) ** exponent) % modulus) # encrypt using RSA, by doing pt raised to the power of exponent (3) modulo the modulus
Output:
25470107759908677227885059212049756476123587149099142377016782162035805692074354189159652091227375655135235368525396923393193646546513521594944466326848816352402770223540805069572455324213054236364701194222702095208890524652925607023595668703783127183044393213645665205889410585077610562587713813622057509622269267198359881821074334152602300114571365555728950484656802303612207021927556708344318318072640242977400728587542260343845271163234654779873505149665431736959069216295088527262802330309349882249615288926177838418478128072496420250629745101514345301311073925631956844826768645400016556267536370392654365461821
454147422122408638236729228778619151840745110573901635266653412884827448174696657067161863712007472045862643664187179466863186606693544670825981955322220612714094448031487713801162618522078593851990811307326192227448461688364355030506264012718298715849972685746984958365293426324609917961631777964113223482455400203888938149651008187748240438990178348789806411004166592944184851235951272579621706914933443403222482532359174060018780965662299105233528835083965863568231382797401795357662064127581799775007005491721985455877597766465099098235202614183072688947734662600789

note: dcode.fr can be used to deal with any large number operations