
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Q1: Secret Messages
Implement a Caesar cipher to encrypt messages.

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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 9 images

Knowledge Booster
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
- write code for :arrow_forwardSolving this problem in the Java languagearrow_forwardLab: Caesar Cipher implementation with Python letters='ABCDEFGHIGKLMNOPQRSTUVWXYZ" KEY=3 def caesar_encrypt(plain_text): plain_text=plain_text.upper() for I in plain_text: index = letters.find(1) index= (index + KEY) % len(letters) cipher_text cipher_text + letters[index] return cipher_text cipher_text=" def caesar_decrypt(cipher_text): plain_text = " for I in cipher_text: index = letters.find(1) index= (index - KEY) % len(letters) plain_text=plain_text + letters[index] return plain_text if name == '_____main__': message = 'Welcome to my Cryptography class' encrypted_message = caesar_encrypt(message) print(encrypted_message) print(caesar_decrypt(encrypted_message)) In the previous page, we define letters as 'ABCDEFGHIGKLMNOPQRSTUVWXYZ' to obtain the index of a character in encryption and decryption. The characters in the plain text and the cipher text have to be from ABCDEFGHIGKLMNOPQRSTUVWXYZ'. In this lab, try to modify the code in the previous page to allow your python code to…arrow_forward
- #4. Task Programming Language and Technologies▪ C# Programming Language.▪ Visual Studio 2019. Build a method called Encrypt to receive a string and return another string.The method will be a static.Build a method called Decrypt to return original string.The encryption method will be a very simple one: to encrypt add 1 to eachcharacter and to decrypt subtract 1 to each character.Note: we do not need to create any object of type Encrypter..arrow_forwardGive the answer to each question. Find the answer my coding using pythonarrow_forwardCrypto Columns The columnar encryption scheme scrambles the letters in a message (or plaintext) using a keyword as illustrated in the following example: Suppose BATBOY is the keyword and our message is MEET ME BY THE OLD OAK TREE. Since the keyword has 6 letters, we write the message (ignoring spacing and punctuation) in a grid with 6 columns, padding with random extra letters as needed: MEETME BYTHEO LDOAKT REENTH Here, we've padded the message with NTH. Now the message is printed out by columns, but the columns are printed in the order determined by the letters in the keyword. Since A is the letter of the keyword that comes first in the alphabet, column 2 is printed first. The next letter, B, occurs twice. In the case of a tie like this we print the columns leftmost first, so we print column 1, then column 4. This continues, printing the remaining columns in order 5, 3 and finally 6. So, the order the columns of the grid are printed would be 2, 1, 4, 5, 3, 6, in this case. This…arrow_forward
- use python pleasearrow_forward21. RSA problem: given plaintext P, e, prime numbers p, q, compute ciphertext C. Decrypt C and verify you get plaintext P back.arrow_forwardExplain what the following lines of code do pad = len(byteblock)%16 * (-1)byteblock_trimmed = byteblock[64:pad]ciphertext = cipher.encrypt(byteblock_trimmed)ciphertext = byteblock[0:64] + ciphertext + byteblock[pad:]arrow_forward
- Deduce a Java program for the concept of Mutual Exclusion by using the following options. ▪ Synchronized method. ▪ Synchronized block. ▪ Static Synchronizationarrow_forwardAlert dont submit AI generated answer.arrow_forwardIn this problem, you will implement a transposition cipher that, instead of dividing the original text into odd and even characters, separates it into three sets of characters. As an example, we will use this 1977 quote by Digital Equipment Corp. president Ken Olson -- "There is no reason anyone would want a computer in their home." (Spaces are represented with the square u-like character.) There is no reason anyone would want a computer in their home. Rail 1: T r S d i t i h a C. e Rail 2: e a u a u in h Rail 3: a W n. m m Example three-rail transposition. The resulting encrypted text is produced by reading the text horizontally, i.e., adding the three rails: Rail 1 + Rail 2 + Rail 3 = **“Trinrs yeoda cpeitihehesoeoao u naournhro.e annnwlwt mt e m" (without the quotes). Requirements: Implement the three-rail transposition cipher above, placing your code in the file p4_2.py (template I provided, replace comment at the beginning of the file with your own code). Feel free to develop your…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education