The ciphertext
was encrypted using a Hill cipher with matrix
Decrypt it.
SOLUTION
A matrix is entered as . Type to multiply matrices and . Type to multiply a vector on the right by a matrix .
First, we need to invert the matrix mod 26:
In[1]:= Inverse[{{ 1,2,3},{ 4,5,6},{7,8,10}}]
Out[1]= {{-, -, 1}, {,, -2}, {1, -2, 1}}
Since we are working mod 26, we can’t stop with numbers like 2/3. We need to get rid of the denominators and reduce mod 26. To do so, we multiply by 3 to extract the numerators of the fractions, then multiply by the inverse of 3 mod 26 to put the “denominators” back in (see Section 3.3):
In[2]:= %*3
Out[2]= {{-2, -4, 3}, {-2, 11, -6}, {3, -6, 3}}
In[3]:= Mod[PowerMod[3, -1, 26]*%, 26]
Out[3]= {{8,16,1}, {8,21,24}, {1,24,1}}
This is the inverse of the matrix mod 26. We can check this as follows:
In[4]:= Mod[%.{{1, 2, 3}, {4, 5, 6}, {7, 8, 10}}, 26]
Out[4]= {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}
To decrypt, we break the ciphertext into blocks of three numbers and multiply each block on the right by the inverse matrix we just calculated:
In[5]:= Mod[{22, 09, 00}.%%, 26]
Out[5]= {14, 21, 4}
In[6]:= Mod[{12, 03, 01}.%%%, 26]
Out[6]= {17, 19, 7}
In[7]:= Mod[{10, 03, 04}.%%%%, 26]
Out[7]= {4, 7, 8}
In[8]:= Mod[{08, 01, 17}.%%%%%, 26]
Out[8]= {11, 11, 23}
Therefore, the plaintext is 14, 21, 4, 17, 19, 7, 4, 7, 8, 11, 11, 23. This can be changed back to letters:
In[9]:= num2txt0[142104171907040708111123]
Out[9]= overthehillx
Note that the final x
was appended to the plaintext in order to complete a block of three letters.