This project explores the mechanics of Stream Ciphers and their vulnerabilities to Frequency Analysis. It includes:
- The Cipher: A tool to encrypt files using XOR logic.
- The Breaker: An automated tool that cracks single-byte XOR encryption using statistical analysis (frequency distribution).
- Bitwise Operations: Using XOR (^) for reversible encryption.
- File I/O: Reading/Writing raw binary streams in C.
- Cryptanalysis: Breaking encryption by analyzing byte frequency (detecting the most common character).
- Compile the Cipher:
gcc cipher.c -o cipher - Encrypt a file:
cipher plain.txt hidden.bin - Compile the Breaker:
gcc breaker.c -o breaker - Crack the code:
breaker hidden.bin
The XOR cipher (unless used as a One-Time Pad with a truly random key equal to the message length) is not cryptographically secure against modern attacks. This tool is intended for educational purposes or simple obfuscation, not for securing sensitive data.