## CPSC 430 Programming Assignments Symmetric Key Encryption

### Implement a Stream Cipher: Due Wednesday, Feb. 2

Write a program in the programming language of your choice (available on cs - Java, C++, Python, PHP) that encrypts each bit of the plaintext by XORing it with a random bit generated by an 8-bit linear feedback shift register with a tap sequence of 7, 3, 0 (that is, it generates the feedback bit by XORing bits at index 7, 3, and 0). You must use bit operations for your implementation.

Your program should read in an 8-bit key (a string of 0s and 1s) that is the starting point for the LFSR and an arbitrary length string of 0s and 1s for the plaintext. The program needs to convert the strings to numeric values to perform the bit operations.

Implement the LFSR as a class. The constructor should take the key as a parameter. The class must provide a method to compute and return the next bit in the random stream (and change the state of the register).

### Implement Simplified Data Encryption Standard (SDES): Due Friday, Feb. 4

Write a program in the language of your choice (available on cs) to implement the SDES algorithm as described in the handout. Implement SDES in a class that provides methods for both encryption and decryption. The class must have the following:
• A constructor that takes a 10-bit key as a parameter. You may choose the format for the parameter - a string, array, or the representation as an integer - clearly DOCUMENT!!!). The constructor must change the parameter to an int for internal calculations.
• Public methods to encrypt and decrypt. These take an 8-bit plaintext (or ciphertext as appropriate) and return a string (or array representation of a string) as the result. This should be clearly documented so the calling program will know how to print the result.
• It must use bitwise operations for all internal calculations (permutations, xor). There should be ONE generic method to perform a permutation on the bits in an int.

Test your program with a program that asks the user for the key and asks if the user wants to encrypt or decrypt, then asks for the 8-bit string to encrypt or decrypt. Print the result.

Extra Credit: Add a feature to your test program that allows it to take a string of characters to encrypt or decrypt.

### Requirements

• Document your program according to these requirements.
• Tar the directory with your program and send the tar file in an email.