Choose the dimensions of the Hill Cipher key matrix.
Define the secret matrix coefficients of size {{ matrixSize }} × {{ matrixSize }}.
Values must be between 0 and 25 (A=0, Z=25).
Auto-calculated for message decryption.
The current matrix determinant is {{ determinant }}. For decryption to be possible, the matrix must be invertible modulo 26, meaning gcd(determinant, 26) = 1. Currently gcd({{ determinant }}, 26) ≠ 1. Please choose invertible values or click the random generator button.
Trace the matrix block multiplication step-by-step.
Real-time simulation assembly
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).