1

Suppose I have a ciphertext that I know is encrypted using an affine cipher in $\mathbb{Z}_{26}$. The plaintext begins with es and the corresponding ciphertext is FX. How can I calculate the key?

Ilmari Karonen
  • 46,120
  • 5
  • 105
  • 181
free
  • 15
  • 1
  • 1
  • 5

1 Answers1

2

Given that you have parts of the plain text and its corresponding ciphertext, this is called a known plaintext attack.

Given an affine cipher that has a key that is composed of 2 parts $a$ and $b$, you can express it as a system of 2 equations with 2 unknown. Assuming the usual mapping $\mathtt{a} \to 0$, $\mathtt{b} \to 1$, etc., you need to solve the following system of linear equations: $$\left\{ \begin{array}{l} 4a+b = 5 \\ 18a+b = 23 \end{array}\right.$$ where the encryption function is $x \mapsto ax+b$. Solve it exactly as you would in $\mathbf{R}$, just be careful when dividing.

fkraiem
  • 8,112
  • 2
  • 27
  • 38