3

I have a question about how I need to solve the following:

A sentence has been changed to ASCII and then encrypted with the formula $E(x) = ax + b \bmod 256256$. All I know is that the first 4 letters are: W I S K

This is the encrypted message:

 064066 158368 092525 143358 099354 141643 110102 051667 024006 190286 133343

How do I go about solving this? I first tried to program a brute force but I actually want to understand how to solve it. I tried working with the extended euclidean algorithm as well, but didn't get far.

2 Answers2

6

W is 87 in ASCII, so $$ 87a+b\equiv064066\pmod{256256}. $$

I is 73 in ASCII, so $$ 73a+b\equiv158368\pmod{256256}. $$

Subtracting, you get $$ 14a\equiv-94302\equiv161954\pmod{256256}. $$

Unfortunately 14 is not coprime to 256256, so you'll need to use other letters to figure this out. Once you get an equation of the form $$ ma\equiv n\pmod{256256} $$ you can solve for $a\pmod{256256}$ and then substitute to find $b\pmod{256256}.$

(In fact, you already have enough to solve with trial and error, but it's nicer to avoid that.)

Charles
  • 528
  • 4
  • 11
1

W = 87; I = 73; S = 83; K = 75

This yields the following system of equations:

$\begin{cases} 87a+b \equiv 64066 \pmod {256256}\\ 73a+b \equiv 158368 \pmod {256256}\\ 83a+b \equiv 92525 \pmod {256256}\\ 75a+b \equiv 143358 \pmod {256256} \end{cases}$

The following proposition is useful.

Proposition If $x \equiv y \pmod {n}$ then $x \equiv y \pmod {n/d}$ for any divisor $d$ of $n$.

You can therefore solve the above system modulo the factors of $256256 = 2^8 \cdot 7 \cdot 11 \cdot 13$.

For example, modulo $7$, we obtain:

$\begin{cases} 3a+b \equiv 2\pmod {7}\\ 3a+b \equiv 0 \pmod {7}\\ 6a+b \equiv 6 \pmod {7}\\ 5a+b \equiv 5 \pmod {7} \end{cases}$

The two first equations (modulo $7$) are impossible. This means that $a$ and $b$ cannot be recovered modulo $7$.

Let us now look modulo $11$:

$\begin{cases} 10a+b \equiv 2\pmod {11}\\ 7a+b \equiv 1 \pmod {11}\\ 6a+b \equiv 4 \pmod {11}\\ 9a+b \equiv 6 \pmod {11} \end{cases}$

The two first equations yield $a\equiv 4 \pmod {11}$ and $b\equiv 6 \pmod {11}$. However, these solutions are incompatible with the two last equations.

I suspect that there are some errors in the problem. Can you check the values of the ciphertext. Or I made mistakes in the calculation...;)

user94293
  • 1,779
  • 13
  • 14