In this assignment you will be implementing an application that can encrypt and decrypt text using the rot13 cipher. This is a very simple (and not very secure) way of encrypting text. Imagine that the alphabet is aranged in a circle as shown below:
|
Each character is encrypted by rotating 13 positions clockwise. For example, the letter 'a' is replaced by the letter 'n', and the letter 'r' is replaced by the letter 'e'. Notice that the encoding is symmetric, since the alphabet has 26 letters. For example, rotating 13 positions from 'n' we get back to 'a'. Uppercase letters are similarly encrypted by rotating 13 positions. Other characters (numerals, punctuation marks, etc.) are left unencrypted. |
Your application should display a window with a scrollable text area where the user can enter text and a button to click to encode or decode the text in the text area. The user can type or paste text into the text area and click the button to encode or decode it.
After pasting some text into the text area, the application should look similar to the following (before and after clicking the Encode/Decode button:
Cipher. You should
have a method to encrypt a single character, and a method to encrypt a String:
public char rot13(char ch)public String rot13(String str)append method in the StringBuilder class
that take different types of parameters. One of them takes a char as parameter.
When your assignment is complete, add some comments to the beginning of the java source code explaining any problems you encountered in completing the assignment and describing any bugs in your solution. Undocumented bugs are worse than documented bugs. If you have undocumented bugs we will assume that you did an inadequate job of testing your code, and you will lose additional points.
Submit your source code file (Cipher.java) as an email attachment to: ttao@umassd.edu. Use the subject line CIS-180 HW#9 in your email. Your UML class diagram may either be submitted in class (hardcopy), or included as a second email attachment (softcopy) with your source code.There will be a 10% penalty for assignments received after the due date. Assignments will not be accepted more than one week past the due date.