# Hill Cipher with unequal matrix

How can we encrypt a text in Hill Cipher with a key matrix that is 3x3 when the plaintext is even like "ATTACKS"? Do we need to add padding like "x" or "z" to make the matrix equal? Thanks.

It's indeed standard to add pre-agreed padding characters at the end to make the plain text a multiple of $$n$$ when we use an $$n \times n$$ encryption matrix.
$$\begin{bmatrix} \operatorname{enc}(A)\\ \operatorname{enc}(T) \\ \operatorname{enc}(T) \end{bmatrix} \begin{bmatrix} \operatorname{enc}(A)\\ \operatorname{enc}(C) \\ \operatorname{enc}(K) \end{bmatrix} \begin{bmatrix} \operatorname{enc}(S)\\ \operatorname{enc}(X) \\ \operatorname{enc}(X) \end{bmatrix}$$
where $$\operatorname{enc}(x)$$ is the encoding of the character $$x$$ in the number ring or field the matrix is taken over, and when we use 'X' as a padding character.
$$\begin{bmatrix}A\\T\\T\end{bmatrix}\ \begin{bmatrix}A\\C\\K\end{bmatrix}\ \begin{bmatrix}S\\X\\X\end{bmatrix}\$$