Affine Cipher Issue

257 Views Asked by At

I'm working through a problem where I need to decrypt a string of text that I know has been encrypted with an affine cipher. I ran a frequency analysis on the letters of the text and Y & W are the most frequent with Y appearing 11 times and W appearing 8.

So I assumed that

  • e --> Y or 4 --> 24
  • t --> W or 19 --> 22

This was wrong and gave me a system of congruences that had no solution. So Next I try the following

  • e --> Y or 4 --> 24
  • t --> H or 19 --> 7

Now I set up a system of equations and get α = 21 & β = 18 and this is still wrong! Heres the weird part I ran the text through a brute force search and its telling me that α=11 & β=6.

What could I be doing wrong? I now know for a FACT that e maps to Y and that t maps to H.. and when I set up the system of equations and solve I don't get the right answer..

1

There are 1 best solutions below

2
On BEST ANSWER

If your guess that $e=4$ is mapped to $Y=24$ and $t=19$ is mapped to $H=7$ is correct, then the parameters $\alpha$ and $\beta$ can be solved from the system of congruences (both modulo $26$) $$ \left\{\begin{array}{ccccc} 4\alpha+\beta&\equiv&24,\\ 19\alpha+\beta&\equiv&7. \end{array}\right. $$ Subtracting the top equation from the bottom one gives $$ 15\alpha\equiv -17\equiv9. $$ The multiplicative inverse of $15$ modulo $26$ is $7$ (as $7\cdot15=105\equiv1$). Therefore this implies that $$ \alpha\equiv105\alpha=7\cdot15\alpha\equiv7\cdot=63\equiv11. $$ Then we can substitute this back to either equation of the original system and get $$ \beta\equiv 24-4\alpha=24-44=-20\equiv6 $$ and as a way of confirmation also $$ \beta\equiv 7-19\alpha=7-19\cdot11=-202\equiv6. $$


Observe that as the most common letters $e$ and $t$ both have an even index, their encrypted versions in an affine cipher will always have the same parity. As $\gcd(2,26)=2>1$ this implies that there will always be some ambiguity when using that particular pair. Either no solutions at all, or more than one solution.