CIS 700 Assignment 2: Playfair Cipher
Summer II 2010, David Matuszek

Purpose of this assignment

To get you started programming in Scala.

General idea

Implement the Playfair Cipher (see the Wikipedia article) for enciphering and deciphering messages.

Assignment details

Input data will come from files (use JFileChooser). The first line of the file will be either encipher keyword or decipher keyword. Remaining lines (zero or more) will be the text to be enciphered or deciphered.

Text to be enciphered will be arbitrary text. It will be mixed case, with spaces and punctuation marks. The output will be all lowercase; letters will be in blocks of 5, starting in the leftmost column, with a single space between blocks (the last block may contain fewer than 5 characters); and there will be ten blocks per line (the last line may have fewer blocks).

Here is an example input (from file):

encipher Pennsylvania
An anonymous reader sends word of a proof-of-concept Google Chrome browser
extension that steals users' login details. The developer, Andreas Grech,
says that he is trying to raise awareness about security among end users,
and therefore chose Chrome as a test-bed because of its reputation as the
safest browser.	

Here is an example output (to the console):

fafaw aermw yqnvm vqyns genwm hwoln kqwow ofkpf nexcq wqfvp
dckqu vhzwn ynmyz unsig wazcl wpxnv ipxey mpiqf asmvw lbvpx
dymvd vaken obefm yinhq pdgyb npxfb zcsvp xzbas cxqki bynfn
bonsn yniar wuynd tqbzp vowad sefxe ymnie fzcym ndqkp dfryn
dckqu vinlw nyzlv mvyfl xenmg axpmy etwlx lwain zcnyf onyzl
kqxny m

Text to be deciphered will be read in from file. The format will be a line providing the keyword, then the enciphered output as above.

If you use classes, please put them all on the same file (it's OK in Scala). Name your object Playfair and your source file Playfair.scala.

Grading

Your program is expected to work; please don't turn in one that doesn't. The penalty for late programs is 10% per day, but it's much more severe if your program doesn't work.

Every method should have Scaladoc comments. Be sure to use the @author tag in the comment for your Playfair object, so we know who you are.

Special rules

The reasons for these rules are twofold: (1) They are intended to get you using some of the unique Scala constructs, and (2) It is easy to write a program to count these keywords.

Due date:

Zip your complete program (source, binaries, scaladoc files) before midnight, Sunday July 18, and submit it via Blackboard.

Common errors: