This repository contains a cryptographic decoding project written in MATLAB. It was developed as part of the CMOR220 course at Rice University during Spring 2024.
The goal of this project is to decrypt an encoded text using letter frequency analysis and probabilistic modeling. The decoder uses a transition matrix of letter probabilities and iteratively searches for the most likely decoding key by maximizing a log-likelihood function.
Project3.m
β Main script with all decoding functions.encodedtext.txt
β File containing the encrypted message.letterprob.mat
β Matrix of letter pair probabilities used for scoring.
- Converts text to numerical ASCII values for processing.
- Implements a stochastic optimization technique (random swaps) to improve the decryption key.
- Uses a transition matrix to evaluate the likelihood of letter pairings.
- Decodes and cleans output by mapping back to readable text.
- ASCII encoding and decoding
- Markov transition matrices
- Log-likelihood scoring
- Monte Carlo-style optimization
- Basic cryptanalysis techniques
Make sure all files (Project3.m
, encodedtext.txt
, and letterprob.mat
) are in the same directory. Then run in MATLAB:
Project3