Hill Cipher

Encode and decode with a matrix key of size two or three, with the determinant, modular inverse and inverse matrix shown.

Hill cipher encoder and decoder

Result: —
—
The matrix must be invertible modulo 26, which means its determinant shares no factor with 26 other than one.

How to use the Hill Cipher

  1. Choose the matrix size and type the key numbers row by row.
  2. Pick encode or decode, then paste the text you want to convert.
  3. Read the determinant and inverse matrix, and copy the result.

Features

Advertisement

Frequently Asked Questions

Common questions about the free online hill cipher.

It is a polygraphic cipher that turns blocks of letters into numbers and multiplies them by a key matrix modulo 26.
Decoding multiplies by the inverse matrix, so a matrix with no inverse modulo 26 cannot be decoded at all.
The determinant reduced modulo 26 must share no common factor with 26 other than the number one.
Two by two and three by three matrices, because larger sizes need much more text in every block.
They are removed before the conversion, because the cipher works on letters and pads text to a full block.
The default is X. Any letter can be chosen, and it is repeated until the letter count fits the block size.
It breaks easily with a known plaintext attack and a little linear algebra, so it is used for puzzles only.
No. The matrix and the text stay in your browser and are never uploaded or stored anywhere.

Last updated: October 10, 2026