RCM3720 Cryptography, Network and Computer Security

Laboratory Class 4: Simple Cryptosystems


We have experimented with the Caesar cipher and the more general translation cipher. We shall start looking at the Vigenère cipher. The trick is to add the correct letter of the code to the letter of the key:
 Index of plain text i: 1  2  3  4  5  6  7  8
             Plaintext: W  I  T  H  D  R  A  W
                   Key: C  O  D  E  C  O  D  E
        Index of key j: 1  2  3  4  1  2  3  4
The indices of the key repeat 1, 2, 3, 4. We can get a repetition of length four by using a modulus of 4:
                     i: 1  2  3  4  5  6  7  8
             i (mod 4): 1  2  3  0  1  2  3  0
What we need to do is to subtract one before the modulus, and add one after:
                     i: 1  2  3  4  5  6  7  8
                   i-1: 0  1  2  3  4  5  6  7
           i-1 (mod 4): 0  1  2  3  0  1  2  3
       i-1 (mod 4) + 1: 1  2  3  4  1  2  3  4
This means that in the Vigenère cipher, we add the i-th character of the plaintext, and the j-th character of the key, where
   j=i-1 (mod n) + 1
with n being the length of the key.