TransWikia.com

How do I decrypt message with RSA algorithm with modulus n = 302446877 and encryption key e 677?

Mathematica Asked by suffering undergrad on April 12, 2021

Message: 196512625 25825210 250970710 140420423 22130212 288711674 26343056

Plaintext is grouped in blocks of 4 letters.

What I have so far =(

Fold[#1 n + #2 &, 0, %];
IntegerDigits[%, 4];
FromCharacterCode[%]

One Answer

This is how to decrypt your message, however I need to know more how to decode the final numbers until I can produce a string, as mentioned in the comments:

n = 302446877;
publicExponent = 677;
{p, q} = FactorInteger[n][[All, 1]];

(* this is the same as EulerPhi[n] *)
phi = (p - 1) (q - 1);

privateExponent = PowerMod[publicExponent, -1, phi];

decryptInteger[c_, d_, n_] := PowerMod[c, d, n]

message = {196512625 , 25825210 , 250970710 , 140420423 , 22130212 , 
   288711674 , 26343056};
decr = decryptInteger[#, privateExponent, n] & /@ message

(* result: {10040415, 2001112, 130303, 14132012, 1041719, 7041417, 236259039} *)

Update: based on @WReach's observation, there is a slight problem with your final number, but essentialy the message is "keep calm and do number theory!"

indices = FromDigits[#, 10] & /@ 
   Partition[Flatten[IntegerDigits[#, 10, 8] & /@ decr], 2];
StringJoin @@ (indices /. Thread[Range[0, 99] -> CharacterRange[97, 97+99]])

(* result: "keepcalmanddonumbertheorz»" *)

Correct answer by flinty on April 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP