Task 2 - Encryption

Task 1

One simple encryption technique is the Caesar cipher. This involves taking the letters of the alphabet and offsetting them by a fixed number of positions to replace letters in the original message (plaintext) by the offset characters. 

For example, an offset of 5 gives the following:

Original Alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ

Offset by 5 we get FGHIJKLMNOPQRSTUVWXYZABCDE

The message COMPUTING IS FUN becomes HTRUZYNSL NX KZS. 

Develop a program to enter, encrypt and decrypt messages.

Task 2

A more secure method of encryption would be to use a keyword. A keyword is the information needed in order to transform the plaintext into the encrypted message and is also used by the recipient to decrypt the message. For example, a keyword could be the letters GCSE. The keyword is repeated enough times to match the length of the plaintext message. The alphabet value (position of the letter in the alphabet) of each letter of the key phrase is added to the alphabet value of each letter of the plaintext message to generate the encrypted text.

For example, if we use the keyword GCSE then we make up the key phrase for COMPUTINGISFUN by repeating the letters within GCSE to make a 14 letter code, GCSEGCSEGCSEGC, where G is the 7th letter of the alphabet, C the 3rd, S the 19th and E the 5th.

Task 3

It is more secure to use two keywords to encrypt data. Whole files may need to be encrypted. Develop a program which can load paragraphs of text from a file, encrypt it twice and then save it to a second file. The program should also be able to decrypt these messages as well.