How secure is Hill cipher

Photo of author
Written By Berry Mathew


In the study of digital communication, a question crosses your mind when it comes to securing it. Are encryption and cryptography the same? Let’s clear that confusion first. Cryptography is a science that involves the process of encryption and decryption. You encrypt data like messages, images, basically anything in electronic form, and the recipient uses decryption to decipher the message.

Ok, so why cryptography? Cryptography is the science that helps you hide away sensitive information while it is passing through the open world of the internet. The Internet, if you look at it from a technical standpoint, is an open system, messages are exchanged between machines with a great deal of visibility, that’s the nature of the internet. You obviously do not want anybody and everybody to be able to see your messages and you obviously cannot stick to non-digital forums for the exchange of sensitive information. Cryptography helps to encode any message into an incomprehensible series of bits using a process called encryption, with an encryption key, that can then be used to decrypt the cryptic message at the receiver’s end. Without the key, the cryptic message cannot be decrypted or understood. Cryptography is based on mathematical theory and computer science.

A comprehensive course on cybersecurity will cover this domain to your satisfaction. If you are interested in understanding the aspects of cybersecurity involving concepts of cryptography, encryption and more, you should take a look at a well-designed Cyber Security Course.

What is a cipher

Ok, we got what is encryption, and what is decryption, and even though at a very high level, some knowledge about cryptography. What is a cipher? Again, a concept in cryptography, cipher is the algorithm, the method or series of well-defined steps to achieve encryption. Cipher defines the key that will be used for encryption and the subsequent decryption. There are many ciphers in use, some popular ones are Steganography, ROT1, Transposition, Public-key cryptography and more.

What is Hill Cipher

In cryptography, the Hill cipher is a Linear Algebra based polygraphic substitution cipher, invented by Lester S. Hill in 1929.

For encrypting a message, each block of letters, let’s say a contiguous sequence of letters from the alphabet, or what we call as words, is multiplied by an invertible nXn matrix Modulo 26, where n is the number of letters in each block, and the matrix is a randomly selected matrix from the set of invertible matrices of the said dimensions. The sequence of numbers thus obtained is converted back to a sequence of letters based on the numbering of letters in the alphabet selected, giving you the final encrypted message.

To decrypt an encrypted message each block is multiplied by the inverse of the matrix that was used to encrypt the message in the first place against Modulo 26. The matrix used is also called the encryption or cipher key. 

Although Hill Cipher is not in practical use any longer, it is a cipher that stands the test of time from a pedagogical standpoint.  Let’s take an example to understand it better.

Understanding Hill Cipher with an example

The example used here is adapted from Wikipedia and is widely used for educational material.

Starting with the input set of letters, or alphabet to be used. Here we assume the English alphabet of 26 letters. Each alphabet is assigned a number in series starting from A all the way up to Z as shown below.

  A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Number 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Number Modulo 26 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

In the cipher model, each number is then represented by Number Modulo 26. Why 26? It is the number of letters in the English alphabet. If you consider a different alphabet, the number will change as per the number of letters in the selected alphabet.

So, the letter A is represented by 0 Modulo 26 = 0. B is represented by 1 Modulo 26 =1 and so on.

Read Also – What to do in Egypt?


Consider a message, which is any sequence of letters from the alphabet, for example, “ACT”.  There are 3 letters in the message, which means, n=3. Select a random nXn invertible matrix which becomes the cipher key.

Let’s say we have selected the matrix

In letter form our cipher key is (GYB/ NQK / URP ) if you substitute the letters with corresponding numbers from the table above.

ACT is converted into vector form as such 

The resulting encrypted message or enciphered vector is then given by

Which corresponds to a “POH”, which is also called ciphertext.


Our ciphertext was POH or . We multiply this by the inverse of the cipher key Modulo 26 which is

Our final expression looks like this

As you can see you have got your original message back after decryption. which is a representation of the original message, ACT.

Read Also: Karmasandhan: Govt Jobs, Recruitment News, Latest Competitive Exams 2021 – Full Analysis


Learning about Hill Cipher is a good way to understand the basics of cryptography, how encryption takes place and how an encrypted message can be decrypted back. If this sparks an interest within you to learn more about cryptography or cybersecurity, you should explore the course on Cyber Security certification from Jigsaw Academy.