Hill Cipher
The Hill Cipher encrypts groups of letters using matrix multiplication and modular arithmetic.
What is the Hill Cipher?
The Hill Cipher is a polygraphic substitution cipher. Instead of encrypting one letter at a time, it converts groups of letters into numbers and treats those numbers as vectors.
A key matrix is multiplied by each plaintext vector. The resulting values are reduced modulo 26 and converted back into letters.
This makes the Hill Cipher especially useful for understanding how linear algebra can be applied to cryptography.
Basic Process
↓
NUMBERS
↓
MATRIX MULTIPLICATION
↓
MOD 26
↓
CIPHERTEXT
Letter Values
Letters are typically converted into numbers:
Example Key Matrix
[ 2 5 ]
With a 2×2 key matrix, plaintext is processed two letters at a time.
Why the Key Matters
Not every matrix can be used as a valid Hill Cipher key. The matrix must be invertible modulo 26 so that the ciphertext can later be decrypted.
Interactive Visualizer
Experiment with a 2×2 matrix below and see how changing its values affects its determinant.
Practice Hill Cipher