# Hill Cipher and Exponential Cipher Questions

1. If p = 29, you intercept the message 16 10 10 09 16 02 22 21 21. Try to break the code and read the message, given that ciphertext 16 is plaintext G. (Note: there is more than one possible exponent that turns ciphertext 16 to plaintext G. You will have to find one that makes the rest of the message make sense.)

So, I know that 16^x can not be congruent to 7 modulo 29, and if we assume A=D, we have to test various exponents such that the intercepted message reads Good Guess.

1. If you know that plaintext AT is ciphertext JK, and plaintext SM goes to ciphertext CU, find the deciphering matrix.

So, I already found that b=21 and d=6 by doing matrices. But,I'm not sure how to proceed.

1. The following is a message encoded with a monographic cipher. What is the decoded message? CBAEB CCADD CCCAC AEBEE CCAEE BCACB DCBBC CDEAC CCCBC BECCD DCDBE ECBDC CCDBC ABEAC CCCBA EEBCB ECDCB EAEEB DACCC CDBDC BEEEA EBCDB CEDCA CDDEB CBBCD CDBCB DCAEE BDACC EBACC CEBCA DCDBE BBBCD CCEDA EEBDB EDCCE BCBEB CABEE DEDCC CACAC EBECD EDACE CDECB EBDBE BCDEC CABCC AAAAA

For this one, I actually have no idea, because I'm not entirely sure what the deciphering key is.

1. Assume that in an RSA system to two primes are 607 and 439, whose product is 266473. Let the enciphering key be e = 205. Encipher the message HELLO. Then find the deciphering key. Note that since you can use three-character groups, you will have to pad: HEL LO? Use S as the padding character.

So, I found that the cipher text is 068660 196630, but now I'm not sure how to find the deciphering key.

I wrote a small Python program trying all $$16^x \pmod {29}$$ and found that $$x=3,10,17,24$$ all give rise to result $$7$$ which corresponds to 'g' (as 'a' = 1 etc, we must work in the units modulo $$29$$, i.e. all nonzero elements.

The first one $$x=3$$ already gives $$10^3 \equiv 14 \pmod{29}$$, so 'n' which is wrong. Trying the other options gave me $$d=17$$ as the decryption exponent, and we get 'goodguess' as the solution.

1. is for Hill, I suppose? What is $$p$$ and the encoding? It's just linear algebra after that.

2. Maybe is a digraphic system? So two letters ciphertext from A-E corresponds to 1 plain letter? A square with A-E on the sides, or encoding letters (minus q maybe) as pairs $$(0,0)$$ to $$(4,4)$$ and and applying a Hill mod 5? Guess an encoding of letters and try it out!

3. Oh no a bad RSA again...($$\begin{rant}$$ why don't they teach proper padding in schools nowadays and why do they use weird encodings and non-random encryption and all sorts of bad habits \end{rant}).

HEL is encoded as 080512 which is $$< n$$ at least? It seems so as then I do get 68660 as the ciphertext, as you do... LOS becomes 121519 which does become 196630 in the ciphertext (which cannot be encoded as letters).

To find $$d$$ compute $$\phi(n)=(p-1)(q-1)$$ and find the inverse of $$e$$ modulo $$\phi(n)$$ using the extended Euclidean algorithm.