Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question

Q1: Secret Messages

Implement a Caesar cipher to encrypt messages.

[画像:a) Create a new Jupyter Notebook and start your program by asking the user for a text to encode and the shift value. Then begin the structure of your program by entering in this loop (we'll build on it more in a bit): encoded Text = "" for letter in text: encoded Text = encoded Text + letter What does this loop do? Make sure you understand what the code does before moving on! b) Now modify the program above to replace all the alphabetic characters with 'x'. For example: Enter text to encrypt: Mayday! Mayday! Enter shift value: 4 The encoded phrase is: Xxxxxx! Xxxxxx! c) Now modify your code, we are going to apply the cipher only to the alphabetic characters and we will ignore the others. So, your program needs to produce the encoded string using the cipher algorithm with the shift value entered by the user. Let's see how one might do a cyclic shift. Let's say we have the sequence: 012345 If we use a shift value of 4 and just shift all the numbers, the result will be: 456789 Page 3 of 5 We want the values of the numbers to remain between 0 and 5. To do this we will use the modulus operator. The expression x%y will return a number in the range 0 to y-1 inclusive, e.g. 4%6 = 4, 6 % 6 = 0, 7% 6 =1. Thus, the result of the operation will be: 450123 Hint: Note that the ASCII value of 'A' is 65 and 'a' is 97, not 0. So, you will have to think how to use the modulus operator to achieve the desired result. Apply the cipher separately to the upper- and lower-case letters. Here is what you program should output: Enter your text to Encrypt: Mayday! Mayday! Enter your encryption key number (1-26): 4 The encrypted message is: Qechec! Qechec! d) Finally, modify your program to decrypt the ciphertext back to the plaintext. (Decryption is the opposite of encryption).]
expand button
Transcribed Image Text:a) Create a new Jupyter Notebook and start your program by asking the user for a text to encode and the shift value. Then begin the structure of your program by entering in this loop (we'll build on it more in a bit): encoded Text = "" for letter in text: encoded Text = encoded Text + letter What does this loop do? Make sure you understand what the code does before moving on! b) Now modify the program above to replace all the alphabetic characters with 'x'. For example: Enter text to encrypt: Mayday! Mayday! Enter shift value: 4 The encoded phrase is: Xxxxxx! Xxxxxx! c) Now modify your code, we are going to apply the cipher only to the alphabetic characters and we will ignore the others. So, your program needs to produce the encoded string using the cipher algorithm with the shift value entered by the user. Let's see how one might do a cyclic shift. Let's say we have the sequence: 012345 If we use a shift value of 4 and just shift all the numbers, the result will be: 456789 Page 3 of 5 We want the values of the numbers to remain between 0 and 5. To do this we will use the modulus operator. The expression x%y will return a number in the range 0 to y-1 inclusive, e.g. 4%6 = 4, 6 % 6 = 0, 7% 6 =1. Thus, the result of the operation will be: 450123 Hint: Note that the ASCII value of 'A' is 65 and 'a' is 97, not 0. So, you will have to think how to use the modulus operator to achieve the desired result. Apply the cipher separately to the upper- and lower-case letters. Here is what you program should output: Enter your text to Encrypt: Mayday! Mayday! Enter your encryption key number (1-26): 4 The encrypted message is: Qechec! Qechec! d) Finally, modify your program to decrypt the ciphertext back to the plaintext. (Decryption is the opposite of encryption).
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education