Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java program to encrypt messages by first applying a Caesar cipher shift to each of the characters in a word/sentence. Next, renumber the

Write a java program to encrypt messages by first applying a Caesar cipher shift to each of the characters in a word/sentence. Next, renumber the alphabet as a series of two digit numbers based on ASCII table. In this way, the letter "A" would be represented as 65 and "B" would be 66. Finally, replace the spaces between the words (if more than one words or in case of a sentence) with '00'.

For example, Utilizing a right shift of 4 cipher with the secret message "I love Java" would produce the following: M PSZI NEZE. Next, converting each letter to two digits based on the ASCII table will produce: 77 80-83-90-73 78-69-90-69. Lastly, adding 00 for each space will yield a two digit grouping of following set of numbers: 77 00 80 83 90 73 00 78 69 90 69.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sample Run:

Enter the message you want to encode: I Love Java

Enter the secret shift amount: 4

After first level encoding the secret message is: M PSZI NEZE

After second level encoding the secret message is: 77 00 80 83 90 73 00 78 69 90 69

Again? (Y/N)? y

Enter the message you want to encode: Learning Java is so fun

Enter the secret shift amount: 19

After first level encoding the secret message is: EXTKGBGZ CTOT BL LH YNG

After second level encoding the secret message is: 69 88 84 75 71 66 71 90 00 67 84 79 84 00 66 76 00 76 72 00 89 78 71

Again? (Y/N)? N

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Use methods:

String firstLevelEncoding(String text, int shift) - Accepts the string in all uppercase that is to be encoded and the shift amount.

String secondLevelEncoding(String origEncoding) - Accepts the basic encoded string in all uppercase.

void printEncoding(String whichLevel, String encodedMessage) - Accepts a parameter indicating which encoding was performed (i.e., "first", "second") along with the encoded message.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

ISBN: 0201844524, 978-0201844528

More Books

Students also viewed these Databases questions