Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i want the answer in python along with the code. Write a Python script to perform a shift (Caesar) cipher. One of the earliest ways

image text in transcribed

image text in transcribed

i want the answer in python along with the code.

Write a Python script to perform a shift (Caesar) cipher. One of the earliest ways that people encrypted information was the shift cipher, also known as the Caesar cipher (after Julius Caesar, who apparently did use the cipher to protect his correspondance across the Roman Empire). In this cipher, each character in a string is replaced by a shifted version of itself. For example, with a shift of 3 (the value Julius Caesar apparently used) the letter "H" can be replaced by "K", "E" can be replaced by "H", "L" by "O", etc.: +3 H 7 10 +3 E 4 7- I +3 L 11 14 O +3 L 11 14 O +3 O 14 17 R Given what we learned in lecture 11 about chr() and ord() and lectures 12 and 13 about defining functions, design a Python function called shift that will: 1. accept a string plaintext and an integer key as parameters (in that order), 2. shift each A-Z and a-z character in the plaintext by the number of spaces specified by the key, leaving all other characters too cncol along and key as parameters (in that order), 2. shift each A-Z and a-z character in the plaintext by the number of spaces specified by the key, leaving all other characters (e.g., space) alone and 3. return the resulting ciphertext string. I would suggest that you: 1. start by assuming that you only need to worry about upper-case characters A-W with shift=3, 2. then consider how to handle letters at the end of the alphabet, 3. only add more cases (lower-case a-z, "special" characters like space and punctuation) after the above works correctly, 4. come up with simple test cases using rot13.com and 5. only convert your algorithm into Python after convincing yourself that it works on paper

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions