Please visit htt ps://en.wikipedia.org/wiki/Caesar cipher. You will be writing code that encrpyts and decrypts using this method. Specifically, you'll be writing functions: E„(x) (x+ n) mod 27 D„(1) (1 – n) mod 27 On the Wiki page, the modulus (%) is 26, but we're using 27-why? We are adding an extra symbol { for space. Please visit https://en.wikipedia.org/wiki/ASCII If you look at the printable ASCII characters, you'll notice that { (hex value 7A) follows z. Thus we can easily extend our cypher to include this symbol for space. Let's see how. 1 sentence "4his is a secret message about the class" 2 sentence.replace (" ", "(") sentence 3 print (sentence) 4 es - for i in sentence: es - encrypt(i, 5) 7 print (es) 6 8 9 ds - 10 for i in es : ds - decrypt (i, 5) 11 12 13 o_sentence - ds. replace ("(", " ") 14 print (o sentence) has output 1 this {is {a{seeret {message{about {the {class 2 ymnxenxefexjhwjycrjxxfljefgtzycy mjchqfxx 3 this is a seeret message about the class In this cypher we are shifting by five. Look at the first letter t. Here is the shift in Python: 1 >>> ord ('L') 2 116 3 >>> chr (ord ('t') + 5) 4 'y' 5 > chr (ord ('h') + 5) 6 m' Line one is our original sentence with { replacing space. Line two is the encrypted sentence. Line 3 the decrypted sentence. The shift is five, so we replace t' with 'y' and 'h' with 'm'. What

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Please visit https://en.wikipedia.org/wiki/Caesar_cipher. You will be writing code that encrpyts
and decrypts using this method. Specifically, you'll be writing functions:
E,(1)
(z+ n) mod 27
D„(1)
(1- n) mod 27
On the Wiki page, the modulus (%) is 26, but we're using 27-why? We are adding an extra
symbol { for space. Please visit https://en.wikipedia.org/wiki/ASCII. If you look at the printable
ASCII characters, you'll notice that { (hex value 7A) follows z. Thus we can easily extend our
cypher to include this symbol for space. Let's see how.
1
sentence
"this is a secret message about the class"
sentence
sentence. replace (" ", "{")
3 print (_sentence)
4
es -
5 for i in
sentence:
es - encrypt (i, 5)
7 print (es)
6
8.
9 ds -
10
for i in es :
11
ds - decrypt(i, 5)
12
13
O_sentence
ds. replace ("{", "
")
14 print (o_sentence)
has output
1 this {is{a{secret{message{about {the{class
2 ymnxenxefexjhwjyerjxxfljefgtzyeymjchqfxx
this is a secret message about the class
In this cypher we are shifting by five. Look at the first letter t. Here is the shift in Python:
>>> ord ('L')
2
116
3 >>> chr (ord ('t') + 5)
4 'y'
5 >> chr (ord ('h') + 5)
6.
'm'
Line one is our original sentence with { replacing space. Line two is the encrypted sentence.
Line 3 the decrypted sentence. The shift is five, so we replace t with 'y' and 'h' with 'm'. What
2.
Transcribed Image Text:Please visit https://en.wikipedia.org/wiki/Caesar_cipher. You will be writing code that encrpyts and decrypts using this method. Specifically, you'll be writing functions: E,(1) (z+ n) mod 27 D„(1) (1- n) mod 27 On the Wiki page, the modulus (%) is 26, but we're using 27-why? We are adding an extra symbol { for space. Please visit https://en.wikipedia.org/wiki/ASCII. If you look at the printable ASCII characters, you'll notice that { (hex value 7A) follows z. Thus we can easily extend our cypher to include this symbol for space. Let's see how. 1 sentence "this is a secret message about the class" sentence sentence. replace (" ", "{") 3 print (_sentence) 4 es - 5 for i in sentence: es - encrypt (i, 5) 7 print (es) 6 8. 9 ds - 10 for i in es : 11 ds - decrypt(i, 5) 12 13 O_sentence ds. replace ("{", " ") 14 print (o_sentence) has output 1 this {is{a{secret{message{about {the{class 2 ymnxenxefexjhwjyerjxxfljefgtzyeymjchqfxx this is a secret message about the class In this cypher we are shifting by five. Look at the first letter t. Here is the shift in Python: >>> ord ('L') 2 116 3 >>> chr (ord ('t') + 5) 4 'y' 5 >> chr (ord ('h') + 5) 6. 'm' Line one is our original sentence with { replacing space. Line two is the encrypted sentence. Line 3 the decrypted sentence. The shift is five, so we replace t with 'y' and 'h' with 'm'. What 2.
about { ? It starts at the beginning at 'a' and returns 'e' which is five spaces. You are free to use
chr and ord in Python or you can make a dictionary. You have complete control on how this is
implemented.
What the arguments to encrypt and decrypt? E,(1) and D,(x) take two parameters each.
The letter and the amount of shift. Observe we retain the shift for all calls to both encrypt and
decrypt.
Writing encrypt and decrypt might be easier if you use a dictionary-but that's entirely up to
you.
Deliverables Problem 4
• Complete encrypt and decrypt. We use { to encode space
• You can use replace()
• a dictionary will likely make the functions more easily implemented
• Provide docstrings for the functions
Transcribed Image Text:about { ? It starts at the beginning at 'a' and returns 'e' which is five spaces. You are free to use chr and ord in Python or you can make a dictionary. You have complete control on how this is implemented. What the arguments to encrypt and decrypt? E,(1) and D,(x) take two parameters each. The letter and the amount of shift. Observe we retain the shift for all calls to both encrypt and decrypt. Writing encrypt and decrypt might be easier if you use a dictionary-but that's entirely up to you. Deliverables Problem 4 • Complete encrypt and decrypt. We use { to encode space • You can use replace() • a dictionary will likely make the functions more easily implemented • Provide docstrings for the functions
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education