Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
Question
Book Icon
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.

Blurred answer
Students have asked these similar questions
A Caesar cipher is a simple substitution cipher based on the idea of shifting each letter of the plaintext message a fixed number (called the key) of positions in the alphabet. For example, if the key value is 2, the word "Sourpuss" would be encoded as "Uqwtrwuu." The original message can be recovered by “reencoding" it using the negative of the key. Write a program that can encode and decode Caesar ciphers. The in- put 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 orig- inal message is replaced by shifting it key characters in the Unicode char- acter set. For example, if ch is a character in the string and key is the amount to shift, then the character that replaces ch can be calculated as: chr (ord (ch) + key). 62
Encrypt Caesar cipher is a kind of substitution cipher. Instead of using a substitution table, the alphabets are rotated by a number (a key). For example, if the key is 3, plaintext alphabet a would become d, and plaintext alphabet z would become c. Write a  program that implements the Caesar Cipher. You program will first prompt for the key and then for the mode (E for encryption and D for decryption) and finally for the message to be encrypted / decrypted. Your program will then output the encryption / decryption message. For this question, the input message may consists of any character, the program should encrypt or small letter case a to z only. All other characters should be kept intact after encryption or decryption.
Substitution ciphers are encryption/decryption algorithms that replace one letter or number with another. The first attested use of a substitution cipher in military affairs was by Julius Caesar, described by him in Gallic Wars (cf. Kahn pp83-84). In caesar cipher , you replace each letter by 3rd letter on. If it is out of bound (later than Z), then round to the head (letter A) and continue the shift. For example:meet me after the toga party PHHW PH DIWHU WKH WRJD SDUWB Please write a program in Java to implement the Caesar Cipher: a. Implement the encryption algorithm. Ask the user to input one all lower case normal sentence (called plaintext) using the nextLine method, and then output the encrypted text (called ciphertext). b. Implement the decryption algorithm. Ask the user to input one encrypted sentence (i.e. ciphertext) using the nextLine method, and then output the decrypted text (i.e. plaintext).
Knowledge Booster
Background pattern image
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