was encrypted using a Hill cipher with matrix
There are several ways to input a matrix. One way is the following. A matrix can be entered as
evalm(M&*N) to multiply matrices and Type
evalm(v&*M) to multiply a vector on the right by a matrix
Here is the encryption matrix.
We need to invert the matrix mod 26:
> invM:=map(x->x mod 26, inverse(M))
map(x->x mod 26, E) takes each number in an expression
E and reduces it mod 26.
This is the inverse of the matrix mod 26. We can check this as follows:
> map(x->x mod 26, %)
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:
> map(x->x mod 26, evalm([22,09,00]&*invM))
[14, 21, 4]
> map(x->x mod 26, evalm([12,03,01]&*invM))
[17, 19, 7]
> map(x->x mod 26, evalm([10,03,04]&*invM))
[4, 7, 8]
> map(x->x mod 26, evalm([08,01,17]&*invM))
[11, 11, 23]
Therefore, the plaintext is 14, 21, 4, 17, 19, 7, 4, 7, 8, 11, 11, 23. Changing this back to letters, we obtain
overthehillx. Note that the final
x was appended to the plaintext in order to complete a block of three letters.