Strict Standards: Declaration of Doku_Renderer_metadata::table_open() should be compatible with Doku_Renderer::table_open($maxcols = NULL, $numrows = NULL, $pos = NULL) in /home2/cp-wiki/htdocs/inc/parser/metadata.php on line 24

Strict Standards: Declaration of Doku_Renderer_metadata::table_close() should be compatible with Doku_Renderer::table_close($pos = NULL) in /home2/cp-wiki/htdocs/inc/parser/metadata.php on line 24

Warning: Cannot modify header information - headers already sent by (output started at /home2/cp-wiki/htdocs/inc/parser/metadata.php:24) in /home2/cp-wiki/htdocs/inc/actions.php on line 581

Warning: Cannot modify header information - headers already sent by (output started at /home2/cp-wiki/htdocs/inc/parser/metadata.php:24) in /home2/cp-wiki/htdocs/inc/actions.php on line 581
cs190c:lab14

Lab 14: First Hour

For today's lab, you are to work independently. You will have one hour to complete the assignment. If, at the expiration of this one hour, you are unfinished, submit what you have finished.

Write a program that will encrypt and decrypt simple lower-case strings using a substitution cipher, like a cryptoquote. The key, or the mapping from the plaintext letters to the code letters is given in cipher.txt. This is only one possible mapping, there are 26!-1 different mappings.

For example, one mapping is called rot13, where the alphabet is rotated halfway.

Where:

A B C D E F G ... 

maps to:

N O P Q R S T ...

You are given the following function that will read the mapping from a file. The function will return a list of pairs. It is your choice how to store the data for easy and efficient lookup. There is more than one good choice, so COMMENT in why you chose to do it this way. This comment is required.

def load_mapping(path):
    """
    Load a mapping stored in a file at path.
    """
    f = open(path)
    mapping = []
    for line in f:
        u,v = line.strip().split()
        mapping.append((u,v))
 
    return mapping

Submit your program on Blackboard. Make sure you hand in everything you produce, as partial credit will be assigned accordingly.