In cryptography, a Caesar cipher is a method of encryption where each character is replaced by a corresponding character a defined number of steps away. Define a cryptographic function, ASCII_shift () that will take in two arguments, a string and a step size. For every alphabetical character in the original string, the function will make a new string which shifts each character in the original string by the defined step size, then print the new string. (You may use the exact comments below in your script.)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Example 2
Enter message to be encrypted: Dèyè mòn, gen mòn.
Enter step size: -1
ORIGINAL MESSAGE
Dèyè mòn, gen mòn.
ENCRYPTED MESSAGE
Cçxç lim, fdm lim.
Enter message to be encrypted: Dèyè mòn, gen mòn.
Enter step size: 0
ORIGINAL MESSAGE
Dèyè mòn, gen mòn.
ENCRYPTED MESSAGE
Dèyè mòn, gen mòn.
Enter message to be encrypted: QUIT
Example 3
Enter message to be encrypted: Perfer et obdura, dolor hic tib:
proderit olim.
Enter step size: 8
ORIGINAL MESSAGE
Perfer et obdura, dolor hic tibi proderit olim.
ENCRYPTED MESSAGE
Xmznmz m| wjl)zi, lwtwz pąk |qją xzwlmzą| wtqu.
Enter message to be encrypted: QUIT
Transcribed Image Text:Example 2 Enter message to be encrypted: Dèyè mòn, gen mòn. Enter step size: -1 ORIGINAL MESSAGE Dèyè mòn, gen mòn. ENCRYPTED MESSAGE Cçxç lim, fdm lim. Enter message to be encrypted: Dèyè mòn, gen mòn. Enter step size: 0 ORIGINAL MESSAGE Dèyè mòn, gen mòn. ENCRYPTED MESSAGE Dèyè mòn, gen mòn. Enter message to be encrypted: QUIT Example 3 Enter message to be encrypted: Perfer et obdura, dolor hic tib: proderit olim. Enter step size: 8 ORIGINAL MESSAGE Perfer et obdura, dolor hic tibi proderit olim. ENCRYPTED MESSAGE Xmznmz m| wjl)zi, lwtwz pąk |qją xzwlmzą| wtqu. Enter message to be encrypted: QUIT
In cryptography, a Caesar cipher is a method of encryption where each character is
replaced by a corresponding character a defined number of steps away.
Define a cryptographic function, ASCII_shift () that will take in two arguments, a string
and a step size. For every alphabetical character in the original string, the function will
make a new string which shifts each character in the original string by the defined step
size, then print the new string. (You may use the exact comments below in your script.)
# FUNCTION: ASCII_shift (original_string, step_size)
# INPUT: original string and step size.
# PROCESSING:
Create a new variable, shift_string.
Iterate over original_string.
For each alphabetical character in original string, convert
the character into Unicode value, add the shift size,
23
23
#3
23
23
convert new value into character, and add the new character
to the end of shift string.
For each non-alphabetical character in the original string,
23
23
23
keep the character the same in the shift_string.
# OUTPUT: returns the shift_string
You will use the ASCII_shift () function in your main () function. In main (), ask the
user to input a message to be encrypted and the step size. Print the original and encrypted
messages. The main () function will continually ask the user for inputs and cali the
ASCII_shift () function until the user enters the word QUIT (all capital) letters.
Below are a few sample runnings in IDLE interactive mode. Underlined text indicates
user input. You can assume there will be no data type entry errors from the user.
Example 1
Enter message to be encrypted: Hello World!
Enter step size: 2
ORIGINAL MESSAGE
Hello World!
ENCRYPTED MESSAGE
Jgnng Yqtnf!
Enter message to be encrypted: 251 Mercer St.
Enter step size: 5
ORIGINAL MESSAGE
251 Mercer St.
ENCRYPTED MESSAGE
251 Rjwhjw Xy.
Enter message to be encrypted: QUIT
Transcribed Image Text:In cryptography, a Caesar cipher is a method of encryption where each character is replaced by a corresponding character a defined number of steps away. Define a cryptographic function, ASCII_shift () that will take in two arguments, a string and a step size. For every alphabetical character in the original string, the function will make a new string which shifts each character in the original string by the defined step size, then print the new string. (You may use the exact comments below in your script.) # FUNCTION: ASCII_shift (original_string, step_size) # INPUT: original string and step size. # PROCESSING: Create a new variable, shift_string. Iterate over original_string. For each alphabetical character in original string, convert the character into Unicode value, add the shift size, 23 23 #3 23 23 convert new value into character, and add the new character to the end of shift string. For each non-alphabetical character in the original string, 23 23 23 keep the character the same in the shift_string. # OUTPUT: returns the shift_string You will use the ASCII_shift () function in your main () function. In main (), ask the user to input a message to be encrypted and the step size. Print the original and encrypted messages. The main () function will continually ask the user for inputs and cali the ASCII_shift () function until the user enters the word QUIT (all capital) letters. Below are a few sample runnings in IDLE interactive mode. Underlined text indicates user input. You can assume there will be no data type entry errors from the user. Example 1 Enter message to be encrypted: Hello World! Enter step size: 2 ORIGINAL MESSAGE Hello World! ENCRYPTED MESSAGE Jgnng Yqtnf! Enter message to be encrypted: 251 Mercer St. Enter step size: 5 ORIGINAL MESSAGE 251 Mercer St. ENCRYPTED MESSAGE 251 Rjwhjw Xy. Enter message to be encrypted: QUIT
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY