In classical cryptography, the Hill cipher is a polygraphic substitution cipher based on linear algebra.Invented by Lester S. Hill in 1929, it was the first polygraphic cipher in which it was practical (though barely) to operate on more than three symbols at once. The following discussion assumes an elementary knowledge of matrices. Each letter is represented by a number modulo 26.
This program has the capability to encrypt or decrypt text based on the key matrix provided. The program takes a matrix of numbersinterpreted as the key for encryption or decryption. In order for the encryption or decryption to be successful, the key matrix input should be invertible.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Prerequisites
What you need to run the program:
Running the Program
In order to run the program, download the source files into the same folder and open hill-cipher.html with a browser of your choice.
Author
- Mussie Habtemichael - mussieh
How often we need to send someone a message and make sure no one else reads it. To encounter this problem the messages sent across to others are encoded more often than not. The algorithms used are as complex as Nazi’s Enigma and as simple as Caesar Cipher. Hill Cipher, invented by Lester S Hill in 1029, is a polygraphic substitution cipher based on Linear Algebra and particular requires the user to have an elementary understanding of the matrices. In this project, we have developed an extended algorithm for Hill Cipher (both for encryption and decryption) and implement it on MATLAB and C++.
Source Code Files
CPP
mainhillcipher.cpp: this file contains 'main' functionencrypt.cpp: this is to write the algorithm of encrypting text using hill cipher
decrypt.cpp: this is to write the algorithm of decrypting text using hill cipher
linearalgebra.cpp: this file contains the basic operations implemented on the matrix
hillcipher.h: this is the header file which binds all the files
MATLAB
Hill_Cipher.m : this file contains 'main' functionEncrypt.m: this is to write the algorithm of encrypting text using hill cipher
Decrypt.m: this is to write the algorithm of decrypting text using hill cipher
Methodology
Encrypt()
Input- A 3x3 matrix which works as a key matrix, key[3][3]
- A plaintext string message
Output
- An encoded string
Constrains
- -32,000 ≤ key ≤ 32,000
- message ∈ {A, B, C …, Y, Z}
Working
- Convert plaintext to ASCII number then subtract 33.
- Multiply key matrix with the plain text and mod92 operator
- Add 33 to the resultant matrix to get the ASCII code of respective elements in the matrix
Decrypt()
Output- Decoded message same as the initial input message
- Finding inverse of key
- Multiply the inverse of key matrix with the ASCII matrix
- Use mod92 operator on the matrix and add 33 to get elements in ASCII form.