2
$\begingroup$

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[%]
$\endgroup$
1
  • $\begingroup$ What does Plaintext is grouped in blocks of 4 letters. mean precisely? I have decrypted your string but I have no idea how it's encoded because you haven't properly specified it (e.g ASCII? Numbers 1-26? Base-8, Base-256 etc.) $\endgroup$
    – flinty
    Oct 27, 2020 at 10:30

1 Answer 1

4
$\begingroup$

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»" *)
$\endgroup$
3
  • 1
    $\begingroup$ The digit pair 00 is a, 01 is b, etc. So the digit pairs 10 04 04 15 are read as keep. keepcalmanddonumbertheor.... The last group appears malformed as it contains four pairs plus a surplus digit. I believe your decryption logic is correct, so either the padding scheme eludes me or there is a transcription error in the message or a mistake was made during encryption. $\endgroup$
    – WReach
    Oct 27, 2020 at 15:20
  • $\begingroup$ Thank you very much for the explanation. $\endgroup$ Nov 1, 2020 at 4:27
  • $\begingroup$ @sufferingundergrad please accept the answer if you feel it solved the problem, otherwise please let me know if you have any other requirements. $\endgroup$
    – flinty
    Nov 1, 2020 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.