# help me please, I'm stuck.

• March 6th, 2014, 05:50 PM
dija
1
Programming Assignment
Encryption Program
In this program you are going to write a class that can be used for encoding and decoding messages. Your program will need two classes. The first class contains the main method and is used to test the second class. The second class contains two public methods. One called Encrypt which takes a string and returns an encrypted (coded) version of the string and one called Decrypt which takes an encrypted string and returns the decrypted (decoded) string. :confused:

Please note that the decrypted message you return must result from the Decrypt method. You cannot just echo the message string.
The Encryption Algorithm
You should build your encrypted text using the following pseudocoded algorithm.
For each character in the message
Get the current character
Convert the character into a two-character hexadecimal string
Create a new character that consists of the concatenation of
a random uppercase character + the first hex digit +
a random uppercase character + the second hex digit
Concatenate this new character to the encrypted text you are going to return
Return the encrypted text.
For example, if you send the message “hi” the hexadecimal code for the “h” is 68 and the hexadecimal code for “I” is 69. Your algorithm should return something like “R6X8T6R9” depending on the random characters generated by your method. Note the random characters interspersed between the 68 and the 69.
2
The Decryption Algorithm
You decryption algorithm needs to restore the original message by removing the random characters to
recover the original hexadecimal code for the character. Remember that each character has been
turned into a 4-character string. So you will have to extract the four encoded characters that make up
each character in the original message as a unit. Also remember that the character you extracted is
coded as a hexadecimal string. To recover the original character from the hexadecimal string you can
use the following line of code
c = (char) Integer.parseInt(character,16);
Here’s a pseudocoded version of the decryption algorithm.
For the length of the encrypted string
Extract 4 characters
Reconstruct the original hex string by removing the 2 random characters
Create the character encoded by the hex string
Concatenate the character to the decoded string you are going to return
Return the decoded string
Before you start this program be sure you have studied the string functions in chapter 4, the for-loop in
chapter 5 and the examples we did in class.
• March 6th, 2014, 06:08 PM
dicdic
Re: help me please, I'm stuck.
Quote: