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:
- review the code in
removeMatchesand compare it to the code you wrote forremoveDupes
what are the similarities? and differences? - implement a version of the substitution cipher algorithm
- complete the algorithm below to generate a stronger key for the subsitution that is based on a user-entered password
- remove the given password's duplicate letters
- divide the alphabet into two parts based on the last letter in the updated password
- remove the letters that appear in the password from both parts of the alphabet string
- 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