Introduction to Computer Science
CompSci 101 : Fall 2013

Cryptography

is ancient and important :)

The goal of this lab is to encrypt messages using a simple letter substitution cipher that replaces each letter in the message with its corresponding one in a substitution key that is derived from a given password.

Start by snarfing the lab code from the course website (alternatively, you can browse code here):

http://www.cs.duke.edu/courses/compsci101/fall13/snarf/

Complete the following steps:

  1. review the code in removeMatches and compare it to the code you wrote for removeDupes
    what are the similarities? and differences?
  2. implement a version of the substitution cipher algorithm
  3. complete the algorithm below to generate a stronger key for the subsitution that is based on a user-entered password
    1. remove the given password's duplicate letters
    2. divide the alphabet into two parts based on the last letter in the updated password
    3. remove the letters that appear in the password from both parts of the alphabet string
    4. return a single alphabet key (i.e., it should be 26 characters long) that is composed of:
      password, back part of alphabet, front part of alphabet