Affine cypher. Find function and plaintext

286 Views Asked by At

I was checking the following Affine Cipher / modular aritmethic exercise:

You intercept a ciphertext YFWD, which was ciphered using an affine cipher. You know that the plaintext starts in ST, find the cipher function and the plaintext $\pmod{26}$

I know $Y → S$ and $F→T$ , also $Y=24,S=18,T=19,F=5$

I've been trying to start from a congruence's equation system like this one:

$$\begin{cases}25 & \equiv & 18a+b\pmod{26}\\ 5 &\equiv & 20a+b \pmod{26}\end{cases}$$

From this point I can't find a way to solve the system, so any help will be really appreciated.

2

There are 2 best solutions below

0
On BEST ANSWER

Subtracting \begin{cases}25 \equiv & 18a+b\pmod{26}\\ 5 \equiv & 20a+b \pmod{26}\end{cases} gives $-20\equiv 2a\pmod{26}$, from which $a\equiv -10\equiv 3\pmod{13}$, that's $a\equiv 3\pmod{26}\lor a\equiv 16\pmod{26}$. In both cases, we get $b\equiv 23\pmod{26}$.

Consequently, the pairs $(a,b)$ of solutions modulo $26$ are: \begin{align} &(3,23)&&(16,23) \end{align}

0
On

Your equations are not quite correct: if the encryption function is $E(x) = ax+b \pmod{26}$ where $x \in \{0,\ldots,25\}$ then we know $E(18)=24$ and $E(19)=5$, so we have the system

$$\begin{cases} 18a + b & = & 24 &\pmod{26}\\ 19a + b & = &5 &\pmod{26} \end{cases}$$

Substracting the first equation from the second eliminates the $b$ and we get $a = 5-24 = -19 = 7 \pmod{26}$ and then substituting this back into the first we get $18\cdot7 + b = 24 \pmod{26}$, so that $b=24 - 126 = 2 \pmod{26}$, and so

$$E(x)=7x+2 \pmod{26}$$

So the decryption function (as the inverse of $7$ modulo $26$ is $15$: $7 \cdot 15 \equiv 1 \pmod{26}$ we get that

$$D(x) = 15(x-2) = 15x - 30 = 15x + 22 \pmod{26}$$

which allows us to decrypt the last part of the message WD = $(22,3)$ and $D(22)=14$, corresponding to O and $D(3)=15$ corresponding to P.