# How to encrypt letters less than block n using Hill Cipher

I am learning about Hill Cipher and know that it is a block cipher where each block of n letters (considered as an $n$-component vector) is multiplied by an invertible $n \times n$ matrix, again modulus $26$.

The article did not touch on what happens if the the block of letters is less than length $n$.

Eg: Assume I am supposed to encrypt 100 letters – how do I encrypt the last 22 letters?

I was thinking of padding similar to MD5, or are there other methods to resolve this issue? If so, what are those methods?

• – Sufiyan Ghori Oct 15 '14 at 14:45
• In the Hill Cipher, the number of components in the vector (that you note $n$) is not usually the same as the modulus you set at $26$. $n=3$ is typical, and makes the padding issue less relevant. Notice that the cipher is slightly less vulnerable if the modulus is prime. – fgrieu Oct 27 '14 at 15:34

• Yes. If the implementation is manual, we can pad with haphazard (non-constant) characters chosen such that a human will understand they are not part of the real plaintext. E.g. ATTACKATDAWNWVK. If a computer is used, why use the Hill Cipher when we have incomparably safer options? – fgrieu Oct 27 '14 at 15:29