Hill cipher
Encrypt or decrypt text with a matrix key, the classic polygraphic cipher from linear algebra.
Hill cipher
The Hill cipher, invented by Lester Hill in 1929, encrypts text by treating letters as numbers and multiplying blocks of them by a square key matrix, modulo the size of the alphabet. Paste plaintext to encrypt it, or ciphertext to decrypt it — this tool runs both directions with the same key.
Choose a 2×2 or 3×3 matrix size, then enter the key either as raw numbers (row by row, separated by spaces or commas) or as a word — its letters fill the matrix in reading order. The alphabet size can be 26 (A–Z only) or 29, which adds space, period and question mark so short phrases keep their punctuation. Characters outside the chosen alphabet are dropped, and accented letters are folded to their plain equivalent first. If the letter count isn't a multiple of the matrix size, the padding letter fills out the last block.
Decryption needs the key matrix to be invertible modulo the alphabet size — its determinant must share no common factor with 26 (or 29). When it doesn't, the tool explains why instead of returning garbage, since a non-invertible matrix has no unique inverse to decrypt with. Turn on "Show matrix, determinant and inverse" to see exactly how the key resolves, which is useful for checking a key by hand or following along with a textbook example.
Everything runs locally in your browser — nothing you type is uploaded anywhere. Copy the result, download it as a .txt file, or send the output straight back into the input to chain another transformation.