i have a ciphertext C=TLNJG formed using the equation

c=(7p+11) mod 27,c equivalent to numerical equivalent character of ciphertext and p the plaintext

how do i get the plaintext back?

for encryption:c=(7p+11) mod 27

for decryption:p=5(c-11) mod 27

let's say i encrypt the letter B(1) I would get

c=(7+11) mod 27

c=18 mod 27=18 (letter S)

but if I do decryption using the decryption equation of the letter S I will get the letter I instead of B.Why?

p=5(18-11) mod 27

p=35 mod 27=8(letter i)


Your formulas are wrong. If $$c \equiv 7p + 11 \mod{27}$$ then by applying the modular arithmetic function $$c - 11 \equiv 7 p \mod{27}$$ and then $$(c - 11) \times 7^{-1} \equiv p \mod{27}$$.

Therefore, the decryption function is: $$p \equiv (c - 11) \times 7^{-1} \mod{27}$$

For this we need to compute de multiplicative inverse of 7 modulo 27. Since they are coprime number, this inverse exists. And we can compute it using the Euler totient method like this:

$$7 ^{-1} \equiv 7 ^{\phi(27) -1} \mod{27}$$

$$\phi(27) = 27 \times (1 - \frac{1}{3}) = 18$$ then $$ 7^{-1} \equiv 7^{17} \equiv 4 \mod{27}$$

Finally the decode function is :

$$p \equiv (c - 11) \times 4$$

For your example:

$$(18 - 11) \times 4 \equiv 7 \times 4 \equiv 28 \equiv 1 \mod{27}$$

| improve this answer | |

I think that for Your problem the simplest (paper) solution is the best.

You need to begin with finding your substitution lookup table. First we need to change letters into numbers. Usually for ciphers like this it's $A=0, B=1, C=2 \dots$ Now we calculate the table. Take every character that can take place in plaintext and calculate the value of it's ciphertext.

$$p=B \implies (7 \cdot 1 + 11) \mod 27 = 18 \mod 27 = 18 \implies c = S$$

Now all You have to do is reverse the table, and walk letter by letter through Your ciphertext to find corresponding plaintext.

About the second part of the question, I believe that You miscalculated: $$7^{-1} \mod 27 = 4$$ Because: $$7 \cdot 4 \mod 27 = 28 \mod 27 = 1$$

| improve this answer | |
  • $\begingroup$ for mod 27(with spaces) does A start with 0 or 1? $\endgroup$ – mr.newbie Mar 7 '16 at 9:42
  • $\begingroup$ I believe that spaces are not encrypted when using standard Caesar cipher. If Your cipher encrypts spaces then A=0. I edited my answer due to awefull miscalculation. $\endgroup$ – Filip Franik Mar 7 '16 at 10:13
  • $\begingroup$ thanks so i got B>S for encryption but for decryption of letter S i got the letter I instead of B,I edited the question to show the steps.Did I do any mistake there?I should get the same letter back and forth for encryption and decryption. $\endgroup$ – mr.newbie Mar 7 '16 at 10:23
  • $\begingroup$ I just updated my answer again a minute ago. I found a little miscalculation that You made. $\endgroup$ – Filip Franik Mar 7 '16 at 10:28

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