Hill Cipher

The Hill Cipher is a polygraphic substitution cipher developed by mathematician L. K. Hill in 1929. It represents one of the first ciphers to use linear algebra, specifically matrix multiplication, to perform encryption, thus providing a more sophisticated method compared to earlier ciphers.

The Hill Cipher works by taking groups of plaintext letters and representing them as vectors. These vectors are then multiplied by a key matrix to produce ciphertext vectors. This method allows for the simultaneous encryption of multiple letters, making it significantly more complex than simple substitution ciphers.

The Hill Cipher was utilized primarily in military and governmental communications due to its enhanced security over traditional ciphers. However, it became vulnerable to certain types of cryptanalysis, especially when the key matrix is known or can be determined through frequency analysis.

Example:

To illustrate how the Hill Cipher functions, let's consider encrypting the plaintext "HELP" using a 2x2 key matrix.

Key Matrix:

Let's use the following key matrix KK:

K=(624113)K = \begin{pmatrix} 6 & 24 \\ 1 & 13 \end{pmatrix}

Plaintext Conversion:

Convert "HELP" to numerical values:

  • H = 7
  • E = 4
  • L = 11
  • P = 15

For the Hill Cipher, we'll group the letters into pairs:

  • Pair 1: HE → (7, 4)
  • Pair 2: LP → (11, 15)

Encryption Process:

  1. Multiply the key matrix by the plaintext vector.

For the first pair (HE):

(624113)(74)=((6×7+24×4)mod26(1×7+13×4)mod26)=((42+96)mod26(7+52)mod26)=(138mod2659mod26)=(47)\begin{pmatrix} 6 & 24 \\ 1 & 13 \end{pmatrix} \begin{pmatrix} 7 \\ 4 \end{pmatrix} = \begin{pmatrix} (6 \times 7 + 24 \times 4) \mod 26 \\ (1 \times 7 + 13 \times 4) \mod 26 \end{pmatrix} = \begin{pmatrix} (42 + 96) \mod 26 \\ (7 + 52) \mod 26 \end{pmatrix} = \begin{pmatrix} 138 \mod 26 \\ 59 \mod 26 \end{pmatrix} = \begin{pmatrix} 4 \\ 7 \end{pmatrix}

For the second pair (LP):

(624113)(1115)=((6×11+24×15)mod26(1×11+13×15)mod26)=((66+360)mod26(11+195)mod26)=(426mod26206mod26)=(1024)\begin{pmatrix} 6 & 24 \\ 1 & 13 \end{pmatrix} \begin{pmatrix} 11 \\ 15 \end{pmatrix} = \begin{pmatrix} (6 \times 11 + 24 \times 15) \mod 26 \\ (1 \times 11 + 13 \times 15) \mod 26 \end{pmatrix} = \begin{pmatrix} (66 + 360) \mod 26 \\ (11 + 195) \mod 26 \end{pmatrix} = \begin{pmatrix} 426 \mod 26 \\ 206 \mod 26 \end{pmatrix} = \begin{pmatrix} 10 \\ 24 \end{pmatrix}

Resulting Ciphertext:

  • From the first pair, we get (4, 7) → "EH"
  • From the second pair, we get (10, 24) → "KY"

Thus, the plaintext "HELP" encrypts to "EHKY" using the Hill Cipher with the specified key matrix. This example illustrates the use of linear algebra in the Hill Cipher to produce ciphertext from plaintext.