Hill Cipher

2661 Words11 Pages
CioheWednesday, April 13, 2016

University of Botswana

ISS 334 LAB 2 ASSIGNMENT
Ndlovu.I 200902852
Ndlovu.I

ISS 334 Lab 2 Assignment

Page 1 of 27

Wednesday, April 13, 2016

Contents
1.

Hill Cipher Description .......................................................................................................................... 3

2.

Question ................................................................................................................................................ 3

3.

Implementation .................................................................................................................................... 3
3.1.

Hill Cipher Encryption and
Step 3 is the same as Step 2 but using a different matrix multiplication to find the key. All the programs have written in java using Dr. Java.

Ndlovu.I

ISS 334 Lab 2 Assignment

Page 3 of 27

Wednesday, April 13, 2016

3.1. Hill Cipher Encryption and Decryption

Ndlovu.I

ISS 334 Lab 2 Assignment

Page 4 of 27

Wednesday, April 13, 2016

3.1.1. Part 1
Class Basic the class has the indexOfChar and indexAtChar method.
The first method matches characters of a string to the alphabet and returns a numeric value, the second method is used to return a char which is located at the position int pos.
Class Hill has an object basic of the class basic so as to access the methods from the basic class, this is done later on in the program.
Class Hill also contains method Hill, this ensures that the matrix we are using is a 2X2 matrix, that’s why the variable block=2.
The method reads the key matrix. The user will enter in the first number and press “enter” and do this until the fourth number is entered. The assumption is that we are using a 2x2 matrix as the key size.

Ndlovu.I

ISS 334 Lab 2 Assignment

Page 5 of 27

Wednesday, April 13, 2016

Ndlovu.I

ISS 334 Lab 2 Assignment

Page 6 of 27

Wednesday, April 13, 2016

3.1.2. Part 2
The method KeyInverse also reads 4 integers which are stored to the double array Key[][] and uses them for the decryption key.
The method encryptBlock is