Hill Cipher Encoder Decoder Online
Encrypt or decrypt text with a 2x2 Hill cipher matrix over the alphabet modulo 26.
How to Use the Hill Cipher Tool
Work with a 2x2 matrix key while keeping the same article rhythm and tool layout as the rest of the category.
Quick Overview
The Hill cipher encrypts text in blocks using matrix multiplication modulo 26. That makes it more mathematical than the other classical pages in this group.
This page keeps the matrix at 2x2 so the controls stay approachable and the output remains easy to verify on short examples. It also validates the matrix before decoding, which prevents one of the most common Hill cipher mistakes. The arithmetic itself relies on modular arithmetic, not ordinary decimal wrapping.
Block Size
This tool uses a 2x2 matrix, so text is processed in pairs.
Input
Input is normalized to uppercase letters only.
Validity
The matrix must be invertible modulo 26 for decoding.
Use an Invertible 2x2 Matrix
The default matrix on this page is the common [3 3; 2 5] example. The determinant must be invertible modulo 26 or the tool cannot decode, which is one reason Hill is usually taught as part of broader classical cipher courses instead of as a casual puzzle.
Process Text in Pairs
Every pair is converted to numeric positions, multiplied by the matrix, and wrapped back into letters with modulo 26. That is why output is grouped in pairs and why odd-length decode input is rejected before the transform runs.
Review the Basic Example
Example Input
HELP
Example Output
HI AT
Decode with the Same Matrix
Decoding requires the inverse matrix modulo 26. Ciphertext also needs an even number of letters because the algorithm works in fixed-size blocks. The result is still part of historical cryptography rather than modern secure encryption. If you want a less mathematical next step, move to Affine Cipher or Playfair Cipher.
Frequently Asked Questions
Why does the tool strip punctuation?
Hill cipher works most cleanly on alphabet-only blocks, so the page normalizes input before processing.
Why do I get an invalid matrix warning?
The determinant of the matrix must be invertible modulo 26, otherwise the matrix cannot be reversed for decoding.
Why is there an X at the end sometimes?
If the text has an odd number of letters, an X is appended so the final pair can be processed.
Why is the output grouped with spaces?
The spaces are only visual grouping for 2-letter blocks. They make the matrix-based output easier to inspect and copy accurately.
Related Tools
ROT13 Encoder / Decoder
Encode and decode text using ROT13 cipher. Rotate letters by 13 positions for simple obfuscation
Caesar Cipher
Encrypt and decrypt text with a configurable Caesar shift from 1 to 25
Atbash Cipher
Encode and decode text using the Atbash mirror alphabet substitution cipher
Vigenere Cipher
Encrypt and decrypt alphabetic text with a keyword-based Vigenere cipher
Morse Code Encoder / Decoder
Convert plain text to Morse code and decode Morse sequences back to readable text
Rail Fence Cipher
Encrypt and decrypt text using the zig-zag rail fence transposition pattern