**QUESTION**

**PYTHON PLEASE**

For number 4 how do you encrypt and decrypt

Encryption is a process of converting a message, image, or any other form of data into encoded data that can only be decoded by someone who can decrypt the message (usually with a key or the like). The science of writing secret codes is called cryptography. For thousands of years, cryptography has made secret messages that only the sender and recipient could read, even if someone captured the messenger and read the coded message. A secret code system is called a cipher.

A good encryption algorithm should produce output that looks random to a bystander but is easily decipherable with the correct key. Thus, encryption algorithms make use of pseudo-random encryption keys.

Let’s start by some definitions:

• Encryption or Enciphering: the process of encoding messages to make them unreadable.

✓ This algorithm has two inputs: a plaintext and a secret key.

• Decryption or deciphering: making encrypted messages readable again by decoding them (recovering plaintext from ciphertext).

• Cipher: an algorithm for performing encryption and decryption.

• Plaintext: the original message.

• Ciphertext: the encrypted message.

✓ Note: a ciphertext still contains all of the original message information, even if it looks like nonsense.

• Secret key: the same key used for encryption and decryption.

• Cryptography: the science of studying ciphers.

For this project, you need to develop a game that converts normal English words into secret codes. In order to convert, the program randomly applies an encryption algorithm on any given message. The algorithms that you need to implement include the Substitution, Playfair, Caesar, Transposition, Product, and RSA ciphers.

1. Substitution cipher: replacing each letter of the alphabet in the plaintext with a different letter in the ciphertext. For example, if you want to encrypt the word ‘Cat’, you need to come up for a substitution for each plaintext letter to a ciphertext letter. For example, you may decide to substitute a letter ‘a’ with the letter ‘o’. The rule is that the letter we substitute can only be used once. So, the letter ‘o’ is crossed off as it has been already used. The same would be applied for all alphabetic letters. You can also substitute a letter with itself. If you are not familiar with this cipher, please visit: Substitution cipher

2. Playfair cipher: is a digraph substitution cipher. It employs a table where one letter of the alphabet is omitted, and the letters are arranged in a 5x5 grid. For more information about this encryption method please visit: PlayfairCipher

3. Caesar cipher: is an example of substitution cipher. If you are not familiar with this cipher, please visit: Caesar cipher Here is an example of Caesar for encrypting a message: Mathematically map letters to numbers: Then the general Caesar cipher is:

4. Transposition (or permutation cipher): rearranging the order of the elements of the plaintext. If you are not familiar with this cipher, please visit: Transposition cipher

5. Product cipher: using multiple stages of substitutions and transpositions. More info: Product cipher

6. RSA: is an encryption algorithm, used to securely transmit messages over the internet. RSA's mathematical hardness comes from the ease in calculating large numbers and the difficulty in finding the prime factors of those large numbers. Although employed with numbers using hundreds of digits, the math behind RSA is relatively straight-forward. If you are not familiar with this algorithm, please read: RSA1 1 You can also visit: https://www.garykessler.net/library/crypto.html for more information .

You need to develop a program that implements the Substitution, Playfair, Caesar, Transposition, Product, and RSA ciphers. The program prompts the user for a message to encrypt, then randomly applies one of the implemented encryption algorithms.

The program contains different classes such as a Message class with two derived classes, plaintextMsg and ciphertextMsg. You may need to include more classes, methods, and attributes.

The Message class contains attributes and methods that could be used to apply a cipher to a string, either to encrypt or to decrypt a message. The plaintextMsg class has attributes and methods to encrypt a message. The ciphertextMsg class contains a method used to decrypt a message. Once the encryption is performed your program needs to display the original message and the encrypted version of it.

The program keeps asking the user for different messages to encrypt until the user inputs ‘Stop’. Once the user asks for STOP, the program display all the plaintext messages, the encrypted versions and the applied method

**PYTHON PLEASE*