Hill Cipher Encoder/Decoder

Enter a 2×2 key matrix (mod 26), check invertibility, then encrypt or decrypt text. We strip non-letters and pad with X if needed.

1. Key matrix (2×2)

Values are integers mod 26 (0–25). A common demo key is [[3, 3], [2, 5]].

2. Text

For decryption, paste ciphertext here and click “Decrypt”.

3. Actions

4. Output

Result

Numeric vector (A=0 … Z=25)

How the Hill cipher works (2×2)

1. Choose a 2×2 key matrix K with entries mod 26.

2. Convert text to numbers using A=0, B=1, …, Z=25, and group into 2-element column vectors.

3. For each vector P, compute C = K · P mod 26. Convert back to letters.

K = [a b; c d], det(K) = ad − bc.
K is invertible mod 26 if gcd(det(K), 26) = 1.

To decrypt, we need the inverse matrix K⁻¹ mod 26 so that P = K⁻¹ · C mod 26. This page computes that for you.


Audit: Complete
Formula (LaTeX) + variables + units
This section shows the formulas used by the calculator engine, plus variable definitions and units.
Formula (extracted LaTeX)
\[','\\]
','\
Formula (extracted text)
K = [a b; c d], det(K) = ad − bc. K is invertible mod 26 if gcd(det(K), 26) = 1.
Variables and units
  • No variables provided in audit spec.
Sources (authoritative):
Changelog
Version: 0.1.0-draft
Last code update: 2026-01-19
0.1.0-draft · 2026-01-19
  • Initial audit spec draft generated from HTML extraction (review required).
  • Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
  • Confirm sources are authoritative and relevant to the calculator methodology.
Verified by Ugo Candido on 2026-01-19
Profile · LinkedIn
, ', svg: { fontCache: 'global' } }; ]], displayMath: [['\\[','\\]']] }, svg: { fontCache: 'global' } };, svg: { fontCache: 'global' } };