Some guidelines for this week's studio:
- Run the PreambleTest and take a look at the output. Make sure you understand why you see what you see. There is a loop printing out each byte as it is received and a String that is printed at the end. The String is the concatenation of all of the bytes received.
- Why does the method return -1 when there are no more characters left?
- Be prepared to explain how this class works to the TA.
Notes:
- You can treat characters ('a') as numeric values, in the sense that you can add to them, etc.
- The lower case characters are contiguous in their representation and are numbered 'a' through 'z'.
- You will have to use mod (%) to return the proper value.
- Arithmetic with the shift value will take place in int world because shift is an int. You will have to cast the result expression to a char before returning anything. Do not change the return type of the methods.
- The code as given to you attempts to encrypt only lower case characters. All other characters are transmitted as supplied. This is the desired behavior.
The TAs can dictate which group you will be. You can avoid such action by finding another group early and sorting this out.
The best way to ensure no problems is for each group to stay logged in and continue using the group's own studio repository. There's no reason to do both Sender and Receiver in the same repository. When you're done, though, take note of the other group's studio name so you can look at the code later.
- The number you choose must be such that 1≤n≤25.
- Keep your number a secret within your group.
Your work from here on should go into the run() method of the Sender class.
Adapter io = new Adapter(new Preamble().getInputStream(20), System.out); io.run();You should see the preamble words printing out in your console.
- The Receiver group must be running their application or your code will fail to connect to the server socket. They should run their application first and then you should launch yours.
- Recall how to get the Socket's output stream.
Now you can see what's being sent as well.
You will have to cast the int to a byte for encrypt to accept it.Try sending to the Receiver again. You should both be seeing the encrypted version.
Did the Receiver team correctly guess your encryption key?
Arrange for your Sender to keep sending until a particular string is typed.
The two teams forming sender and receiver must be on the same network, meaning that the first three numbers of your IP addresses should match. If this is not the case, one or both of the groups should move to a lab computer. Commit your work first!
I checked out the machines in the lab, and at least port 3000 is available. If you have trouble offering service on that port at some point, you can try another.
Your work from here on should go into the run() method of the Receiver class.
If your other group is not ready, try to find a group that is and interact with them to test this out so you can move forward.
Your job is to analyze the messages coming across the Socket and determine the value of the key for the cipher. The key value will be in the range 1≤n≤25.
- Some ideas were given in class.
- Write a class that analyzes properties of interest concerning the text you are receiving.
It is not acceptable to try all 25 keys at once. You must show the TAs that you have cleverly determined the key.
When you done with this studio, you must be cleared by the TA to receive credit.
- Commit all your work to your repository
- Fill in the form below with the relevant information
- Have a TA check your work
- The TA should check your work and then fill in his or her name
- Click OK while the TA watches
- If you request propagation, it does not happen immediately, but should be posted in the next day or so