top of page
CS 251 Ciphers - Breaking Classical Codes with C++

A cryptography tool for encryption, decryption, and heuristic key recovery.

CS Project • C++ • Solo Developer • 3 weeks • File I/O • Algorithms
Overview

For my CS 251 course at UIC, I built a C++ command-line tool that encrypts, decrypts, and breaks classical ciphers using heuristic search. The program supports Caesar and substitution ciphers, English-ness scoring, hill-climbing, dictionary-based scoring, and quadgram evaluation.

Context Problem
  • Built for CS 251: Data Structures Algorithms.

  • Goal: Encrypt, decrypt, and crack ciphers.

  • Solve unknown substitution keys using heuristics.

  • Work with real text files and datasets.

Process
Menu System

Designed a simple text-based interface allowing users to choose cipher type, encrypt/decrypt, load files, and run the substitution attack.

Caesar Cipher

Implemented clean helper functions for character shifting, alphabet wraparound, and brute forcing all keys when the shift is unknown.

Substitution Cipher + Hill Climbing

Built a heuristic solver using scoring functions, dictionary matching, quadgrams, random key generation, letter swapping, and hill-climbing optimization.

File I/O + Testing

Used file reading, writing, and unit testing to validate encryption, decryption, and hill climbing using large real-text datasets.

Challenges: What I Learned
  • Balancing readability vs correctness.

  • Debugging subtle scoring + indexing bugs.

  • Managing large file I/O and long strings efficiently.

My Role
  •  Solo developer.

  • Implemented Caesar + Substitution logic.

  • Built hill-climbing key recovery.

  • Added dictionary + quadgram scoring.

Outcome

Built a full cryptography tool capable of encrypting, decrypting, and cracking classical ciphers. Strengthened my understanding of heuristic search, C++ architecture, and multi-file projects.

bottom of page