Hill Cipher

Encrypt or decrypt using an n×n key matrix over the alphabet (mod 26).

Client-side only. Data never leaves your device.
Input is normalized to A–Z and padded with X so length is a multiple of n (2).

How to use Hill Cipher

1

Enter n² numbers for an n×n key matrix (e.g. 4 numbers for 2×2, 9 for 3×3).

2

Make sure the matrix is invertible mod 26 (gcd of the determinant and 26 must be 1).

3

Choose Encrypt or Decrypt and type your text.

4

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.

ToolsPDFImageDevText