Question: In cyber security, encryption is a method of masking the contents of a document or string such that it may only be read by the

In cyber security, encryption is a method of masking the contents of a document or string such that it may only be read by the participating parties. This has been widely used for many centuries with one of the first known encryption method being used by Julius Caesar to communicate with his generals. Essentially, Caesar would write his communications to his generals and then apply a 'key' to the communication, which would enable the encryption. This is known as a caesar cipher. The key in the caesar cipher is used as a shift parameter that shifts a letters value by some amount. An example of the caesar cipher applied to the alphabet can be seen below: key: 1 original text: abcdefghijklmnopqrstuvwxyz cipher text: bcdefghijklmnopqrstuvwxyza You will notice from the example of the alphabet, that each letters value is shifted to the right in the alphabet by 1, which is the key. Thus, 'a' + key => 'b' If the key was 5, then: key: 5 original text: abcdefghijklmnopqrstuvwxyz cipher text: fghijklmnopqrstuvwxyzabcde The pattern you have probably noticed by now is that the last characters of the alphabet will wrap around back to the beginning of the alphabet. This is necessary because the alphabet only has 26 characters and in the times of Rome, they did not use ASCII values. Thus, any caesar cipher implementation should perform the following operation in pseudocode on each character in the string: cipher_character = original_character - a cipher_character = (cipher_character + key) % 26 cipher_string = cipher_string + (a + cipher_character) What is happening in this pseudocode is a three step process to convert a character: 1. Because characters are stored in ASCII, convert the character to a value between 0 and 26 2. Add the key to the value found in step 1 to shift the character and use the remainder operator to ensure we are constrained to the characters of the alphabet 3. Append the character to our output string (i.e., cipher_string) after converting it back to a character. There are many things we have not covered yet in order to fully understand and implement this lab. * Items from Python required for this assignment: You will notice from the above text that we need to convert the characters of a string from ASCII values to non-ASCII values and back. We do this because, as you recall from some of your labs and the previous open lab assignment, you cannot perform mathematical operations on strings. To perform the shift operation with the key, we must convert these characters to integers. To do this in Python, we can use the ord() function. An example of this can be seen below: value = ord(a) print(value: , value) The value that is printed when executed is: 97. Likewise, if we wish to convert from an integer, ASCII value to a string representation, we can use the built-in chr() function. This function takes one argument, which is an integer, and will return the character representation of that integer. An example of this can be seen below: value = chr(97) print(value: , value) The value that is printed when executed is: a * Requirements: In this open lab assignment, you will implement the functionality of a caesar cipher as described above. Your program will perform the following operations: 1. Ask the user to input a string 2. Ask the user to input a key 3. Apply the key to each alphabetic character of the string and develop a cipher string 4. Print the cipher string for the User An example of the expected output of your program can be seen below: 370 ranger0$ python3 cipher.py Please enter a string to encrypt: abcdef Please enter a key: 2 cipher: cdefgh Another example demonstrates how your program should handle longer, more complicated strings: 371 ranger0$ python3 cipher.py Please enter a string to encrypt: Cybersecurity can be fun sometimes... Please enter a key: 1 cipher: Dzcfstfdvsjuz dbo cf gvo tpnfujnft... As you see, only the alphabetic characters (a-z, A-Z) are affected by the caesar cipher. That is how your program should operate and you will note that some strings are not affected by the caesar cipher. 372 ranger0$ python3 cipher.py Please enter a string to encrypt: 1 + 2 = 3 Please enter a key: 4 cipher: 1 + 2 = 3 * Turn-in: You are required to electronically submit the source program, a source program listing, and the execution results of a run with some input data of your choosing that adequately tests your program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!