CIT 591 Assignment 5: Playfair Cipher
Fall 2008, David Matuszek
You are probably familiar with the idea of "secret codes," such as the cryptograms published in some newspapers. A cipher is a more secure way of making secret messages. In this assignment you will write a program to encipher and decipher secret messages according to the Playfair cipher. (For more about the Playfair cipher, see the Wikipedia article.)
Here's how to construct a Playfair cipher.
university. j occurs in the keyword, change it to i. (So university is not changed.) university becomes universty.) u |
n |
i |
v |
e |
r |
s |
t |
y |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
j.
u |
n |
i |
v |
e |
r |
s |
t |
y |
a |
b |
c |
d |
f |
g |
h |
k |
l |
m |
o |
p |
q |
w |
x |
z |
Here's how to encode a message, using the array:
j to i.
x as the second letter. x instead of the second letter.
(The second letter will be the first letter of the next group of two.) x, use q instead
of the second letter. (The second x will be the first letter of
the next group of two.) id become tl, while up becomes ru. st become ty,
while lo becomes mh. sm becomes yk. Example:
Programming in Java is fun!
programminginjavaisfun
programminginiavaisfun
pr og ra mx mi ng in ia va is fu nx
ub zo sr xv lv ec vi et ey tn bv vq
ubzos rxvlv ecvie teytn bvvq
Here's how to decode a message, using the array:
Example:
ubzos rxvlv ecvie teytn bvvq
ub zo sr xv lv ec vi et ey tn bv vq
pr og ra mx mi ng in ia va is fu nx
This is as far as you can get in decoding the message. The message is readable, with a little effort on the human's part.
Create a project named PlayfairCipher. Create a package named playfair.
Get
CipherExpert.zip, unzip it, and add the files
to your playfair package. Use this as your skeleton to get started.
Do not change the names or parameters of any of the provided
method stubs!
Write a program to encipher and decipher messages using the Playfair cipher,
using CipherExpert as your "main" class. Each provided method
has Javadoc comments that tell you what the method is supposed to do.
Write JUnit tests for every method in each of the provided classes, except
the CipherExpert class and the printInBlocksOfFive method
in the StringUtilities class. Whichever of your team members
writes a method should also write the unit tests for that method.
Write an AllTests.java test suite to run all your unit tests at once.