The Wheat Square Cipher is a simple encryption technique for
encoding plaintext messages.
The encoding scheme uses a keyword which in real life is
known only to the correspondents. The letters of the
keyword are used to create a "code block," which is a 5 by 5
matrix of letters. Since the code block is limited to 25 letters,
if the keyword contains the letter "J" it is changed into an "I"
any place that it occurs. The keyword is then written into
the square by rows, omitting repeated letters. Follow the keyword with
the rest of the alphabet's letters in alphabetical order.
Each letter of the alphabet occurs once and only once in
the code block. You may assume the keyword contains no blanks.
For example, the keyword "Villanova" would produce this code
block:
To encode a message, first prepare the message text as follows:V I L A N
O B C D E
F G H K M
P Q R S T
U W X Y Z
"),
put
an 'X
' in between them (so "LETTER
"
becomes "LETXTER
"). (If the repeated
letters
are themselves 'X
',
do not place an 'X
' between them.)
Notice that in step 3, 'JI' becomes 'II'
which is considered a double letter for step 4.X
'
at
the end of the message.The encoding process works like this:
AM
" becomes "NK
", WD
" becomes "YB
", Using the keyword "Villanova",
Another example - the keyword "Jackpot" would produce this code block:is encoded as:
Amazingly few discotheques provide jukeboxes.
NKNYLVHIUKBZBARDEPMCPWDTQSFOABBNYFOCCUDT
Then "I A C K P
O T B D E
F G H L M
N Q R S U
V W X Y Z
bonus
" is encoded as: "DTQNRY
".Write a program that encodes messages using the Wheat Square Cipher.
You must follow this Java class
definition:
public class WheatSquareCipher
{
/** Construct a cipher from a given keyword.
* @param keyword the keyword to use for
encoding the cipher.
* @pre keyword contains no blanks.
*/
public WheatSquareCipher(String keyword)
/** Encode a plaintext message using the
cipher.
* @param message a string of
characters
to be encoded.
* @return String coded message
*/
public String encode (String message)
}
Note: Please design your own solution.
While this algorithm is easy
to find on the Web or in textbooks, please write your own algorithm
from
scratch. Do not use the internet or other resources for any
purpose related to ciphers or encryption. discotheques
" example
above. This output can
be created in one of two ways:
Write a JUnit test class and print the test source code and the successful test runner output.
Write a driver and a file of test input data. Print the driver source code, the input data file, and the execution output.
Perform any additional tests you want to convince yourself that your solution is correct.
In addition, your program must pass
the
instructor's acceptance test. Once you are satisfied that
your
program is correct and is passing your unit tests, create a new
time
log entry. Enter "Test" for the phase and in the
comment field enter "Acceptance Testing". (You may use
"Accept
Test" for the phase if you prefer. Do not count this phase
as
development time in your summary).
Submit your source code using the Web-CAT grader. On this project the grader will not run your own unit tests. Web-CAT will report checkstyle errors in red and they WILL count in your total score. Each coding standard violation is a defect. The defect type is 10 for code syntax, and 80 for Javadoc errors. (Tip: To avoid getting style errors in Web-CAT, run the Checkstyle extension in BlueJ before submitting to Web-CAT.)
If Web-CAT reports any errors, tally
them in a new section of the defect tally without an inject phase,
with a removal phase of
"ACCEPTANCE TEST". Don't add them to Injected Phase or total
on the Summary form. You are allowed five Web-CAT
submissions without penalty. If you take more than five
submissions, your project earns only half-credit.
When Web-CAT assigns a 100% score to your work, you should finalize your work according to the assignment directions.