0
$\begingroup$

I have a set of numeric values that are supposed to represent a message encoded via textbook RSA. For example:

60889
37946
13359
61629
35960
13747

I've decrypted these values to find the corresponding messages:

1535
3109
2789
1191
2700
1829

Now I need to convert these values the alphabetic using the rule that each value represents a triplet of alphabetic characters as follows:

DOG -> 3*(262) + 14*26 + 6 = 2398
CAT -> 2*(262) + 0*26 + 19 = 1371
ZZZ -> 25*(262) + 25*26 + 25 = 17575

I'm not sure how to find the alphabetic characters once I have the original numeric message. The only way I could think to do it would be to calculate every possible triplet combination of letters then find the numeric match for each element. But this method seems way overly complicated.

Anyone have a better way to figure this out? I'm writing this all in Java, so a code example would be even better!

$\endgroup$
  • 1
    $\begingroup$ The actual formula is $a\cdot 26^2+b\cdot26+c$ ($26^2$, not $262$). If there were instead 10 letters and you had to turn $a\cdot 10^2+b\cdot 10+c$ into $(a,b,c)$, how would you go about it? $\endgroup$ – cpast Feb 21 '15 at 2:55
  • $\begingroup$ Hint: when you have an integer in range [000..999] on a computer, how do you break it into 3 integers having the value of each decimal digit? Do the same with base 26 instead of base 10. $\;$ BTW, RSA is not used in that way. $\endgroup$ – fgrieu Feb 21 '15 at 18:38
1
$\begingroup$

The term you are looking for is Modular Arithmetic.

In the case of 1535, if it is indeed a combination of 3 values ranging 0 to 25, you do the following:

1535 mod 26 = 1
(1535 - 1) / 26 = 59
59 mod 26 = 7
(59 - 7) / 26 = 2

The set of values that generated 1535 is 2,7,1 (c,h,b?), which can easily be verified.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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