Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( JAVA JAVA JAVA ) PLEASE USE A METHOD TO CODE THIS. Suppose you have managed to intercept a message that reads as follows: :mmZdxZmx]Zpgy

( JAVA JAVA JAVA ) PLEASE USE A METHOD TO CODE THIS. Suppose you have managed to intercept a message that reads as follows: :mmZ\dxZmx]Zpgy The message is encrypted using a secret code. You have just learned that the encryption method is based upon the ASCII code (Appendix 7 in your textbook). Individual characters in a string are encoded using this system. For example, the character a is encoded using the number 97 and b is encoded using the number 98. The code depends on a Secret key which is an integer value. This secret code takes each letter of the message and encrypts as follows:

if(originalChar + key > 126) then EncryptedChar = 32 + ((originalChar + key) - 127) else EncryptedChar = (originalChar + key) 3 For example, if one uses Key = 10 then the message Hey would initially be represented as Character ASCII code H 72 e 101 y 121 And Hey would be encrypted as: Encrypted H = (72 + 10) = 82 = R in ASCII Encrypted e = (101 + 10) = 111 = o in ASCII Encrypted y = 32 + ((121 + 10) - 127) = 36 = $ in ASCII

Consequently, Hey would be transmitted as Ro$. Write a Java program that decrypts the intercepted message. You are only told that the key used is a number between 1 and 100. You can assume that the original message consists entirely of ASCII codes that represent only printable characters. Your program should try to decode the message using all possible keys between 1 and 100. When you try the valid key, the message will make sense. For all other keys, the message will appear as gibberish. Since there are only 100 keys this would obviously be a pretty crummy encryption system. Use the String method charAt() to handle each character in the String. This problem requires you to explore a bit on your own how to convert from a char to a number, process the number and then convert it back to a char. You cannot use the encryption method for decryption. You should first find the decription formula for the two cases you are given, and then test using your formula on the paper to see if it works on a single word that you first encript and using your formula decrypt and see if you can get back your original word. There is a \ in the encrypted code. You need to escape encode it by using \\ if you hard code it in your program. This method should return a String.

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_2

Step: 3

blur-text-image_3

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

Describe effectiveness of reading at night?

Answered: 1 week ago

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago