# Hill Cipher in C and C++ (Encryption and Decryption)

Here you get encryption and decryption program for hill cipher in C and C++.

What is Hill Cipher?

In cryptography (field related to encryption-decryption) hill cipher is a polygraphic cipher based on linear algebra. Invented by Lester S. Hill in 1929 and thus got it’s name. It was the first cipher that was able to operate on 3 symbols at once.

Also Read: Caesar Cipher in C and C++ [Encryption & Decryption]

Encryption: The given message string and key string is represented in the form of matrix. Then key and message matrix are multiplied. Finally modulo 26 is taken for each element of matrix obtained by multiplication. The key matrix that we take here should be invertible, otherwise decryption will not be possible.

Decryption: The encrypted message matrix is multiplied by the inverse of key matrix and finally its modulo 26 is taken to get the original message.

https://en.wikipedia.org/wiki/Hill_cipher

## Hill Cipher Program in C++

Output

Comment below if you have any queries related to above program for hill cipher in C and C++.

## 6 thoughts on “Hill Cipher in C and C++ (Encryption and Decryption)”

1. daniel

is there any encryption and decryption code in php? if yes, what’s the code….

2. Milind Jakati

Hey! I was wondering if there is a code for the above in Ruby?

3. Gokila.M

Explain this line: I know fmod is used to calculate modulo but why you are adding +97……
printf(“%c”, (char)(fmod(encrypt[i][0], 26) + 97));