CIT 590 Assignment 12: Caesar Cipher
Fall 2016, David Matuszek
Purposes of this assignment
- To give you an easy assignment over the Thanksgiving holiday.
- So that you don't forget all your Java over the holiday .
The Caesar cipher is one of the oldest encryption techniques, and
certainly one of the easiest to break.
The idea of a Caesar cipher is this: you encode a message by shifting
each letter some number of places. Thus, if the shift is 2, then A becomes
C, B becomes D, and so on. It is end around, so Y becomes A and Z becomes
B. Like this:
For an accurate Caesar cipher, we would discard all punctuation, and group
the text into blocks of five letters. We won't do that here; we will retain
all spacing and punctuation, and all capitalization. This will enable us to
decipher messages to get exactly the original message.
Name your project
Caesar, and your package
Create a class
Caesar containing at least the following two
You may provide a
String encipher(int shift,
- Enciphers the
message, using the
shift to be any integer value; use the
mod operator to cut it down to a value between 0 and 25.
- Given any message enciphered using a Caesar cipher, decipher it and
return the deciphered message.
main method if you feel like it, but it
In Java, a
char is another type of integer value, so you can
do arithmetic with it. However, the result will not be a
int, so you have to cast it back to a
You should work directly with characters in your program, don't write them
as numbers. You can rely on the fact that the lowercase letters all have
consecutive numeric values, and so do the uppercase letters.
Write unit tests for the above methods, and for any other I/O free methods
you write. Name your test class
How to do it
and save the word list at http://www-01.sil.org/linguistics/wordlists/english/wordlist/wordsEn.txt.
A message will be correctly deciphered when it consists of mostly
English words. It doesn't have to be entirely English words-that's too
strict a test. The message may contain other things, such as the names of
people or places.
Zip your Scala project and turn the zip file in to
Canvas. Due by 11:59pm
Tuesday, November 29.