Example illustrating the Hill encryption algorithm

This section provides an example illustrating the use of the Hill encryption algorithm. To make it easier to follow the steps that need to be performed with CrypTool, the example is illustrated with a number of screenshots.

To start with, here is a brief summary of the steps to be performed.

The text HILLCIPHER is to be encrypted with the key T E S T.

Key:
T
E
Corresponds to: 19 4
 
S
T
  18 19

As the key consists of two rows and columns, the text has to be divided up into blocks of two characters.

H
I
 
L
L
 
C
I
 
P
H
 
E
R
7 8   11 11   2 8   15 7   4 17

To encrypt the first block, the following calculations are performed:

7 * 19 + 8 * 18 = 277 = 10 * 26 + 17 = 17 (modulo 26),

7 * 4 + 8 * 19 = 180 = 6 * 26 +24 = 24 (modulo 26).

Hence the first block of the encrypted text is: 17 24. This corresponds to R Y.

The entire encrypted text reads as follows:

R
Y
 
R
T
 
A
E
 
V
L
 
S
B
17 24   17 19   0 4   21 11   18 1

If CrypTool is given a plaintext and the corresponding encrypted version of that text, it is able to perform a successful attack on the Hill encryption algorithm and work out the key, as will be seen below.

We shall now examine the individual steps in detail.

The text HILLCIPHER is to be encrypted with the key T E S T. To do this, a new document is created (via File \ New) and the text HILLCIPHER is entered. Under the classical encryption algorithms lower case letters are always replaced by the corresponding upper case letters. However, CrypTool keeps upper and lower case letters distinct in order to make the text easier for you to read. These two aspects can be disabled independently of each other via the options Keep characters not present in the alphabet unchanged and Keep uppercase / lowercase (if possible) in the Text Options dialog box. Therefore it does not matter whether the text contains lower case letters. To demonstrate this we will use Hillcipher instead of HILLCIPHER:

szenariohill1.gif

We now select Crypt/Decrypt \ Classical \ Hill, following which this dialog box appears:

szenariohill2.gif

After entering the key T E S T it can be saved in the clipboard (in order to avoid having to enter it again later on at the decryption stage) by clicking on the Copy button. Information on the clipboard will be found in the Help facility on the toolbar. Now click on the Encrypt button, and a new window that contains the encrypted text opens.

szenariohill3.gif

The encrypted text is now decrypted for checking purposes. The decryption procedure is identical to encryption, except that this time the Decrypt option must be selected, i.e. the radial button next to that option must be selected. This is done by clicking on the field with the mouse. The key can now either be typed in manually as before or else it can be inserted from the clipboard using the Paste button if it had previously been copied.

szenariohill4.gif

Now click on Decrypt, and the plaintext reappears.

szenariohill5.gif

CrypTool will now work out the key using a Known Plaintext attack. Such an attack requires that both the plaintext and the encrypted text are available. The easiest approach is to copy the plaintext (mark with the mouse pointer and then press the key combination Ctrl+C) from one of the two windows which contain Hillcipher to the clipboard. Now make the window containing the encrypted text the active window again (by clicking on it with the mouse) and select the menu option Analysis \ Known Plaintext \ Hill to view the Analysis Hill cipher window. The plaintext is then pasted from clipboard into this window (using the key combination Ctrl+V).

szenariohill6.gif

The analysis starts when the Continue button is clicked and the key T E S T appears in the following window.

szenariohill7.gif

In this way the key was worked out simply from knowing the plaintext and the corresponding encrypted text.