CS 341: Cryptography

Implementing DES

Hand in via the Courses folder by 8:30AM Monday, Jan 24.

For this assignment, you will implement the block cipher portion of DES. That is, you will write a program that takes a 64-bit plaintext, a 64-bit key (whose individual bytes are required to have odd parity), and a flag asking for either encryption or decryption, and produces a 64-bit ciphertext.

Your program should adhere to the following command-line syntax:

python des.py [encrypt|decrypt] key text

where both key and text are 16-digit hexadecimal numbers, and key represents a sequence of 8 bytes, each of which has odd parity. For example,

python des.py encrypt 73b5f4fd4043e5fb 6d79206d6f6f7365

will produce the DES encryption of the 8-byte ASCII message "my moose" using the 64-bit key 73b5f4fd4043e5fb. Note that every byte in the key has odd parity. For example, 73 hex = 01110011 binary, which has an odd number of 1's.

Your program should print the ciphertext to standard output as a 16-digit hexadecimal number.

Some notes