The Hill cipher is a polygraphic substitution cipher built on concepts from Linear Algebra. The Hill cipher makes use of modulo arithmetic,
Polygraphic substitution is a uniform substitution where a block of letters is substituted by a word, character, number, etc.
Since the Hill cipher is fairly complex, let’s encrypt the text “CODE” and, later, decrypt the resulting ciphertext to understand how the Hill cipher works. To keep the example simple, we will use a straightforward substitution scheme where the letter A is mapped to 0, B is mapped to 1, etc. to stick to a 2x2 key matrix. The complexity of the Hill cipher increases with the size of the key matrix.
Encrypting with the Hill cipher is built on the following operation:
Decrypting with the Hill cipher is built on the following operation: