Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
expand_more
expand_more
format_list_bulleted
Question
Chapter 5, Problem 7PE
Program Plan Intro
Program to encode and decode caesar cipher
Program plan
- Inside the “main()” function,
- Declare “plaintext” and “key” and get input from the user.
- Declare “ciphertext” and then encode the plaintext into ciphertext.
- Print the encoded message.
- Call the “main()” function.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A Caesar cipher is a simple substitution cipher based on the idea of shiftingeach letter of the plaintext message a fixed number (called the key) ofpositions in the alphabet. For example, if the key value is 2, the word"Sourpuss" would be encoded as "Uqwtrwuu." The original message canbe recovered by "reencoding" it using the negative of the key.Write a program that can encode and decode Caesar ciphers. The input to the program will be a string of plaintext and the value of the key.The output will be an encoded message where each character in the original message is replaced by shifting it key characters in the Unicode character set. For example, if ch is a character in the string and key is theamount to shift, then the character that replaces ch can be calculated as:chr (ord(ch) + key) .
Simple python code
Python question
Simple python program
Chapter 5 Solutions
Python Programming: An Introduction to Computer Science, 3rd Ed.
Ch. 5 - Prob. 1TFCh. 5 - Prob. 2TFCh. 5 - Prob. 3TFCh. 5 - Prob. 4TFCh. 5 - Prob. 5TFCh. 5 - Prob. 6TFCh. 5 - Prob. 7TFCh. 5 - Prob. 8TFCh. 5 - Prob. 9TFCh. 5 - Prob. 10TF
Ch. 5 - Prob. 1MCCh. 5 - Prob. 2MCCh. 5 - Prob. 3MCCh. 5 - Prob. 4MCCh. 5 - Prob. 5MCCh. 5 - Prob. 6MCCh. 5 - Prob. 7MCCh. 5 - Prob. 8MCCh. 5 - Prob. 9MCCh. 5 - Prob. 10MCCh. 5 - Prob. 1DCh. 5 - Prob. 2DCh. 5 - Prob. 3DCh. 5 - Prob. 4DCh. 5 - Prob. 5DCh. 5 - Prob. 1PECh. 5 - Prob. 2PECh. 5 - Prob. 3PECh. 5 - Prob. 4PECh. 5 - Prob. 5PECh. 5 - Prob. 6PECh. 5 - Prob. 7PECh. 5 - Prob. 8PECh. 5 - Prob. 9PECh. 5 - Prob. 10PECh. 5 - Prob. 11PECh. 5 - Prob. 12PECh. 5 - Prob. 13PECh. 5 - Prob. 14PECh. 5 - Prob. 15PECh. 5 - Prob. 16PE
Knowledge Booster
Similar questions
- Write a Program using any programming language you are comfortable with to implement Ceasar Shift cipher technique. The algorithm should take “plaint text” and key as input and gives the cipher text as output.arrow_forwardHow to create a Caesar cipher program with the given rules?arrow_forwardImplement the first round of AES ( Advanced Encryption Standard ) in python. Given a message with 128 bits, two subkeys subkey0 and subkey1, your program should be able to perform one AddKey before Round 1 and the corresponding operations (SubBytes, ShiftRows, Mix-Columns, and AddKey) in Round 1, and output the result of the encryption after Round 1.arrow_forward
- 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: QUITarrow_forwardWrite a Java program to encrypt and decrypt a phrase using two similar approaches, each insecure by modern standards. The first approach is called the Caesar Cipher, and is a simple "substitution cipher" where characters in a message are replaced by a substitute character. The second approach, due to Giovan Battista Bellaso (b 1505, d 1581), uses a key word, where each character in the word specifies the offset for the corresponding character in the message, with the key word wrapping around as needed.arrow_forwardWrite a python program that scans in a large number of tweets from a file, and prints the top 5 hashtags. Approach Parse each word in the file Find a way to isolate the hashtags from the rest of the tweet Compute the frequency of each unique hashtag. Find the top 5 hashtags. Caveats 1. Because this is public dataset, there are many tweets that use special characters that may cause issues during reading in your file. To avoid this, explicitly specify the encoding mode in open when reading in the file. with open('twitter_data.txt', 'r', encoding='utf8') as f: 2. When parsing hashtags be sure to change everything to lowercase. There are cases in the file where two hashtags are the same but differ in case. 3. There is no standard way of sorting a dictionary based on the values. Python gives you access to a sorted function where you can pass in a collection and also specify a comparator which outlines how you want to sort the values. This can be done with a one line lambda function.arrow_forward
- could you please code this on notepade.arrow_forwardA simple and very old method of sending secret messages is the substitution cipher. You might have used this cipher with your friends when you were a kid. Basically, each letter of the alphabet gets replaced by another letter of the alphabet. For example, every 'a' get replaced with an 'X', and every 'b' gets replaced with a 'Z', etc. Write a program thats ask a user to enter a secret message. Encrypt this message using the substitution cipher and display the encrypted message. Then decryped the encrypted message back to the original message. You may use the 2 strings below for your subsitition. For example, to encrypt you can replace the character at position n in alphabet with the character at position n in key. To decrypt you can replace the character at position n in key with the character at position n in alphabet. Have fun! And make the cipher stronger if you wish! Currently the cipher only substitutes letters - you could easily add digits, puncuation, whitespace and so forth.…arrow_forwardProgram Specifications: Your task is to write a program that can decrypt a message that has been encoded using a Caesarcipher. Stated another way, you need to find the “shift” for the cipher. Once you have the shift,you know the mapping so you can decrypt the message. the encryption code. use python. def encrypt(text, r): #abcdefghijklmnopqrstuvwxyzresult = ''for i in range(len(text)): # Hello Khoorchar = text[i]if char.isupper():result = result + chr((ord(char) + r - 65 ) % 26 + 65)else:result = result + chr((ord(char) + r - 97) % 26 + 97)return result while True:msg = input("\n\tEnter a String / message e.g. Today is Thursday ")rotation = int(input("\n\tEnter number of rotation e.g. 3 "))print("\n\tOriginal Message is==> ",msg," with rotation ",rotation, " The CypherText ", encrypt(msg,rotation)) No hand written and fast answer with explanationarrow_forward
- write a program in python as implementation of decryption of affine cipher. output should be:encrypted message is:....decrypted message is:..... plaint text: cryptologya coefficient: 3b coefficient: 1arrow_forwardThe Reflection algorithm can be used to encrypt a C-string (character array terminated with the null character) before it is transmitted over the Internet. The Reflection algorithm works as follows: Each letter in the message is converted to the letter in that is 13 positions to the right of that letter in the English alphabet. If the end of the alphabet is reached, counting continues from the first letter in the alphabet. The case of the letters must be maintained. For example,'M' →'Z', 'x' → 'k', 'A' → 'N'The numeric characters ('0' to '9') are shifted 5 positions to the right of that number in the character set '0' to '9'. If ‘9’ is reached, counting continues from ‘0’. For example,'0' → '5', '2' →'7', '8' → '3' All other characters are left as they are. a) What would the following string be encrypted to by the Reflection algorithm?“Call me at 662-2002 Ext 85393” b) Write a function, getPosition, which finds the position of a letter in the alphabet regardless of the case of the…arrow_forwardThe language used for the code is fortran 2008. Thank you 1. There are many algorithms that can be used to encrypt a message. One of these algorithms can be described as follows: • Choose a “code word”. For example, “fortran”. • Assign integer values to each of the characters in the code word corresponding to their placement in the alphabet. In the case of the code word “fortran”, the integer values would be (6, 15, 18, 20, 18, 1, 14). • Change each character in the message to be encrypted by adding the code word values determined above (in order) to each of the characters in the message to be encrypted. The code word is reused as many times as necessary. For example, suppose that we want to encrypt the message “hello”, we would first determine the integer values for each character in the message (8, 5, 12, 12, 15). Each of these values would be modified by adding the code word values, ie. (8+6, 5+15, 12+18, 12+20, 15+18) = (14, 20, 30, 32, 33). The resulting values are then translated…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