HILL CIPHER

Yash Waghmare
2 min readOct 15, 2020

Alice and Bob want to sent a message so that even if Eve intercepts it, she cannot tell what it is. We will allow Alice and Bob a short private meeting to exchange information (or perhaps they will use RSA or Diffie-Helman for that). But the key can’t be that long and has to be reusable (so one-time pad does not qualify). I describe below a well known cipher called the Hill Cipher.

Invented by Lester S. Hill in 1929, the Hill cipher is a polygraphic substitution cipher based on linear algebra. Polygraphic substitution is a uniform substitution where a block of letters is substituted by a word, character, number, etc. Hill used matrices and matrix multiplication to mix up the plaintext.To counter charges that his system was too complicated for day to day use, Hill constructed a cipher machine for his system using a series of geared wheels and chains. However, the machine never really sold.

ENCRYPTION

Each letter is represented by a number modulo 26. Often the simple scheme A = 0, B = 1, …, Z = 25 is used, but this is not an essential feature of the cipher. To encrypt a message, each block of n letters (considered as an n-component vector) is multiplied by an invertible n × n matrix, against modulus 26.

E(K, P) = (K*P) mod 26

Where K is our key matrix and P is the plaintext in vector form. Matrix multiplying these two terms produces the encrypted ciphertext.

KEY
KEY

P = A T T

DECRYPTION

To decrypt the message, each block is multiplied by the inverse of the matrix used for encryption. The matrix used for encryption is the cipher key, and it should be chosen randomly from the set of invertible n × n matrices (modulo 26).

D(K, C) = (K-1 *C) mod 26

Where K is our key matrix and C is the ciphertext in vector form. Matrix multiplying the inverse of the key matrix with the ciphertext produces the decrypted plaintext.

--

--