# Python Steal Or Deal and Caesar Encrypting/Decryption - 74396

Solution Posted by

Rating : (19)A+
Solution Detail
Price: \$40.00
Request Description

Part I: Steal or Deal?
You are required to write a Python program that allows a player to play a game of Steal or Deal against the computer. The program will allow a player to play at most 10 games of Steal or Deal but the player can stop before he/she has reached his/her 10 game limit. Once the player chooses to stop playing or the player has played 10 games, the program will report the game statistics to the screen.
Part II: Encryption
You are required to write a Python program that performs simple encryption and decryption on strings entered by the user. To do so, you are to use one of the simplest and most widely known encryption techniques known as the Caesar Cipher. The Caesar Cipher is named after Julius Caesar who used it for private correspondence.

STAGES (PART I)

It is recommended that you develop this part of the assignment in the suggested stages. Each stage is worth a portion of the marks. Many problems in later stages are due to errors in early stages.

The following stages of development are recommended:

Finally, check the sample output (see section titled ‘Sample Output – Part I’ towards the end of this document) and if necessary, modify your code so that:

The output produced by your program EXACTLY adheres to the sample output provided.

Your program behaves as described in these specs and the sample output provided.

PART II SPECIFICATION - ENCRYPTION

A simple way to encrypt data is attributed to Julius Caesar, the Roman Emperor. (If you are interested, you may like to read the following… http://en.wikipedia.org/wiki/Caesar_cipher). This method takes each character in a message and replaces it with one which is a certain distance (offset) along the alphabet from it (moving right).

For example:

1 2 3 4 5 6 7 8 9 . . . . .

A B C D E F G H I J K L M . . . +3 à

A B C D E F G H I J . . .

If the offset is 3 then A becomes D, B becomes E, C becomes F etc. In this case the word DIG encrypts to GLJ. In order to decrypt the word/string, simply offset by the same amount moving in the opposite direction (i.e. moving left).

Instead of restricting the cipher to the alphabetic characters only, we will use all of the printable ASCII characters. That is, all the characters from ASCII 32 (Space) to ASCII 126 (~).

Write a menu driven program called yourEmailId_encryptor.py that will allow the user to enter commands and process these commands until the quit command is entered.

The following commands should be allowed:

1. Encrypt string:

Prompt for and read (from the keyboard) a string to be encrypted. The program should then ask for the offset value (limited to a range of 1 to 94 inclusive). Display the encrypted string to the screen.

2. Decrypt string:

Decrypt an encrypted message by prompting for and reading (from the keyboard) a string to be decrypted. The program should then ask for the offset value (limited to the range of 1 to 94 inclusive). Display the decrypted string to the screen.

3. Brute force decryption:

If the offset is not known, we can implement a brute force decryption algorithm that tries all of the 94 possible Caesar offsets in order to decrypt the encrypted text. Prompt for and read the string to be decrypted and display all 94 possible decrypted strings to the screen. (If you are interested, you may like to read the following… http://en.wikipedia.org/wiki/Brute-force_attack).

4. Quit:

Quits the program displaying a goodbye message to the screen.

Your program must work with the printable ASCII character set. That is, all the characters from ASCII 32 (Space) to ASCII 126 (~). When the offset points to a character beyond 126 it should wrap around to the beginning of the set.

For Example:

If the offset is 4 and the character is ‘}’ (ASCII 125) then it will encrypt to ASCII 129. This is beyond 126 so wrap back to the beginning by subtracting the total number of characters (95). This gives character 34. Similarly when decrypting, if the subtracted offset results in a number less than 32 then add 95 to the result. 15 of 36

STAGES (PART II)

It is recommended that you develop this part of the assignment in the suggested stages. Each stage is worth a portion of the marks. Many problems in later stages are due to errors in early stages. Make sure you have finished and thoroughly tested each stage before continuing.

Finally, check the sample output (see section titled ‘Sample Output – Part II’ towards the end of this document) and if necessary, modify your code so that:

The output produced by your program EXACTLY adheres to the sample output provided.

Your program behaves as described in these specs and the sample output provided.

Solution Description

Python St

Attachments