Update 1, 4/13/2013

Code Cracking

For this assignment, you will write a program that breaks the (weak) encryption on a given message. Our goal is to learn about security and encryption methods and to gain experience them.

Implementation guidelines

As you read about substitution ciphers, keep in mind that Caesar ciphers are a special case of the general class of substitution ciphers. For the substitution cipher portion of this assignment, you may implement any of the general class of substitution ciphers.

To aid your cracking, you'll want to use the dictionary of words that I provide on our Eureka page. However, your program should still crack messages that contain a small number of misspelled words or words that do not appear in the dictionary.


  1. Learn about Substitution Ciphers. For our first foray into encryption and code breaking, we will focus on an old (and not secure) method known as substitution ciphers. I recommend that you read Secret Bits: How codes became unbreakable, by Hal Abelson, Ken Ledeen and Harry Lewis. For this assignment, only the first part of the chapter is relevant, but I encourage you to read the entire chapter as it may help with subsequent parts of the project.
  2. Write a simple substitution cipher. Write a class, SubstitutionCipher, that encrypts a text file, given as a command-line argument, and writes the encrypted text of the file to the standard output. For our purposes, we will only use 29 characters: the 26 uppercase letters of the alphabet, space, period and question mark. Your program should convert lowercase letters to uppercase but should silently ignore other punctuation and special characters besides the three listed above. Because I am not specifying a particular substitution cipher, you should provide ample documentation for your design choices within your code.
  3. Decode my encrypted message. Write a class, CrackCipher, that will take as input (via a single command-line argument) a file containing the encrypted text of a message and recovers the original message, printing it in plain text to the standard output. Note, the encrypted text need not be generated by your own SubstitutionCipher program. Because the particular substitution cipher for part 2 is not specified, this would be a good opportunity to share encrypted messages with your friends to test your CrackCipher program. Update 1: In order to keep the computation time at a reasonable level at this point of the project, you should generate test messages that use a small subset of the 29 characters in our allowable alphabet. Furthermore, you should try to generate a plaintext message that shares letter-frequency properties with the source that you are using (e.g., Crime And Punishment). The encrypted message, m3enc.txt, that I provide on Eureka is easily cracked with a small beam-width. Ultimately, your task is to decrypt the message that I provide (on Eureka); I will use a simple substitution cipher (not a one-time pad nor Vigenere cipher) but not necessarily a Caesar cipher. I will be looking for a correct recovery of my original text as well as for a speedy solution.

Submission Instructions:

On your machine where you are doing your homework, create a folder called <your email name> followed by “P01”. For example, someone with email address “cjones” would create a folder called “cjonesP01”. Inside that folder, place plain text file(s) containing your answers to any written questions required of you. Also, place whatever Java and documentation files are necessary for your programming project in the same folder. Finally, either tar or zip the folder so that when I extract it, the folder ”<emailname>P01“ will be created. Finally, submit via Eureka.