Vignere Cipher

Here we will take a look at the Vigenere Cipher. This cipher is performed by first choosing a secret code word. The code word is known by both the sending party and the recieving party. The plaintext and the code word are then both encoded according to some scheme. We then take the encoded message, and we add the first number of the codeword to the first number of the plaintext, the second number of the codeword to the second letter of the plaintext, and so on until we reach the end of the message, repeating the codeword as many times that is necessary. Let the secret code word be CAT, and let our encoding scheme be $A\rightarrow 00$, $B\rightarrow 01$, $\dots$, $Z\rightarrow 25$. \[ \begin{array}{ccccccc} & A & T & T & A & C & K \\ & 00 & 19 & 19 & 00 & 02 & 10 \\ & C & A & T & C & A & T \\ + & 02 & 00 & 19 & 02 & 00 & 19 \\ \hline & 02 & 19 & 12 & 02 & 02 & 03 \\ & C & T & M & C & C & D \end{array} \] Run the following code to define all necessary functions, then proceed to the examples.

Example

Here we have an example of this code in use. We use the same message as the example above, as well as the same code word. We call the VigenereEncrypt() method to encrypt the word ATTACK, then we demostrate the VigenereDecrypt() function to decrypt the message CTMCCD.