Linear Algebra Cryptography Simulator
Current Mode: {{ mode.toUpperCase() }}
The matrix determinant modulo 26 is {{ determinant }}. To encrypt/decrypt using the Hill Cipher, the determinant must share no common factors with 26 (i.e. $\gcd(\det, 26)$ must be 1). Otherwise, the decryption matrix $K^{-1}$ will not exist. Go to the Matrix Config tab and load a valid preset or click random generate.
Determinant: $\det = {{ determinant }}$. Inverse Det: $\det^{-1} \pmod{26} = {{ modularInverse }}$.
$K^{-1} = \det^{-1} \times \text{adjugate}(K) \pmod{26}$. This matrix decrypts the ciphered blocks back to cleartext.
The **Hill Cipher** is a polygraphic substitution cipher based on linear algebra, invented by Lester S. Hill in 1929. It encrypts groups of letters (blocks) simultaneously using matrix multiplication.
Where K is the N×N key matrix, P is the plaintext block vector, and C is the resulting ciphertext block vector.
Where K-1 is the modular multiplicative inverse of the matrix K.
For the inverse matrix K-1 to exist modulo 26, the determinant of
K must be coprime to 26:
• det(K) ≠ 0
• gcd(det(K), 26) = 1 (The determinant must not share
factors with 26, meaning it cannot be divisible by 2 or 13).