Cryptography: Ciphers and Algorithms

From UCLA IEEE Advanced Projects
Jump to: navigation, search

This project is meant to help the participants develop a basic understanding of cryptography. As this field is enormous, constantly expanding, and not capable of being well understood until studied in a proper course, we will not worry about building systems that are cryptographically secure in a modern sense, but rather in the sense that humans would have some difficulty decrypting the ciphertext by hand.

The first rule of cryptography is not to write your own algorithms. There are myriad ways in which an attacker could analyze your methods as well as your output to determine behavior and build exploits. One example of such an approach is a side channel attack. Reading that Wikipedia article should convince you that without years of graduate research and an intimate understanding of discrete mathematics and other advanced subjects, you will not be able to write an algorithm that at least one person can't easily break.

With that in mind, let's break the rule!

  • The C++ and Python code for this project can be found here: project code

Tier 1

You will attempt to implement a basic cipher (choose from the list below) in C++ or python. Provided here (no link yet) is the Project 2 code folder. Inside are skeleton programs in C++ and python, each which contain an unimplemented cipher_encrypt() and cipher_decrypt() function. Both functions accept two arguments, a string to encrypt/decrypt, and a key (an integer). They each return a string, being ciphertext in the case of cipher_encrpyt(), and plaintext in the case of cipher_decrypt(). The main routine in each program will test your encrypt and decrypt functions to ensure that they perform correctly on a limited set of test cases. Once you are satisfied with your implementation, you will submit the code.

Note: It is possible for your key to be something other than an integer, in the sense that you can encode other information in an integer. For example, you could treat 32 bits of the key as 4 ASCII characters, to be used in a block shift cipher.

The ciphers allowed are:

  • Caesar (shift) cipher
  • Substitution cipher
  • Vignere cipher
  • Transposition cipher


  • Your code file(s), in a .zip archive. If you are using the C++ skeleton code and do not modify anything but main.cpp, you may submit main.cpp by itself.

Tier 2

After Tier 1 is submitted, three cipher programs will be chosen at random, and distributed to all of the teams. For each of these three, you will read the code and attempt to determine a method for decrypting the message without the key. The new test code will call cipher_encrypt() on a selection of English text (important!) with a randomly generated key, and then call cipher_break() on the resulting ciphertext. You will implement cipher_break() with your decryption method for each of the three programs. The best average performance cipher_break() routine for each of the three ciphers will win this tier. The output of your cipher_break() algorithm will only be tested on the correctness of alphabetic output (i.e., if the input text contains punctuation or numbers, you are not required to accurately reproduce them in your output).

Due date: 1/30/15


  • Your code file(s), in a .zip archive. If you are using the C++ skeleton code and do not modify anything but main.cpp, you may submit main.cpp by itself.