Hill Cipher
Encrypt or decrypt using an n×n key matrix over the alphabet (mod 26).
Cryptography
You might also like
Caesar Cipher
Encrypt or decrypt text using a classic shift cipher with adjustable rotation.
Vigenère Cipher
Encrypt or decrypt text using a keyword-based polyalphabetic substitution cipher.
Playfair Cipher
Encrypt or decrypt text using a 5×5 digraph cipher square built from a keyword.
How to use Hill Cipher
Enter n² numbers for an n×n key matrix (e.g. 4 numbers for 2×2, 9 for 3×3).
Make sure the matrix is invertible mod 26 (gcd of the determinant and 26 must be 1).
Choose Encrypt or Decrypt and type your text.
Copy the output.
Frequently Asked Questions
Why does the key need to be invertible?
Decryption requires the modular inverse of the key matrix. If it doesn’t exist, you cannot decrypt.
What sizes work?
Any n×n matrix with n ≥ 2. Enter exactly n² numbers (row by row).
What alphabet is used?
A–Z mapped to 0–25, with all other characters removed for the transformation.
Is Hill Cipher secure?
No. It’s educational and can be broken with modern methods.
Why use Kitbase Hill Cipher?
Any square size
Supports 2×2, 3×3, and larger n×n keys — not just digraphs.
Matrix validation
Warns when the key matrix is not invertible mod 26.
Classic linear algebra cipher
Encrypts letter blocks of length n with matrix multiplication.
Demo included
Load a working key and sample input instantly.
Privacy-first
Runs locally in your browser.