Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This task will have you implementing a very simple (and very easy to break) encoding system, but the concepts you use to do so are

This task will have you implementing a very simple (and very easy to break) encoding system, but the concepts you use to do so are at the heart of more advanced ones as well. You should be sure to read through the SingleShift sample code before working on this to familiarize yourself with some Java syntax and problem solving approaches that will be useful here. The core idea was actually used in early online discussion groups as a way to make a post unreadable at first glance, but easy to decode once a person decided they wanted to read it. Our Task 2 system is called Rot32. Since there are 64 valid characters in this project when it comes to messages, one way to easily encode and decode a message is to "rotate" each character by 32 positions. This means that the same algorithm can be used to encode and to decode messages. It also means that as soon as someone knows our approach, all of our messages can be instantly decoded by the enemy. One subtle point is that you need to rotate "around" the end of the valid UNICODE range. For example, the letter H has an UNICODE value of 72. When you add 32 to this you get 104. However, we said we'd only be using characters between UNICODE positions 32 and 95. The way we handle this is that if the new value is greater than 95, we simple "wrap around" to the start of our range. To do this, we can subtract 64 (the range of values we have) from the number, and we will have essentially have "wrapped around" the valid character list. We now have 40, which is ( in UNICODE. Using this system, the message Hello class would first need to be changed to HELLO CLASS and then encoded as (%,,/@#,!33. Work this out by hand using the ASCII part of the UNICODE table to make sure you are comfortable with the idea. There is one method to implement:

 public static String rot32(String message) 

The parameter message will refer to a String object. Your code will need to iterate through this character by character, "rotate" that character by 32 positions, and then use it as part of a new String that you will return at the end of the method. Don't forget that we will only be using upper-case letters! Once again, you might find the .toUpperCase method that all String objects can invoke is useful. Then, take this algorithm and hand write the pseudocode or Java code that you think would accomplish this "rotate 32" task.

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

DEFINE human resources planning (HRP) and

Answered: 1 week ago

Question

Question Who can establish a Keogh retirement plan?

Answered: 1 week ago