A lightweight, pure-Swift command-line engine implementing standard cryptographic ciphers and data compression algorithms from scratch.
This project was built to demonstrate core computer science principles—such as tree data structures, bitwise operations, dictionary-based compression, and polyalphabetic substitution—using clean Swift syntax and modern software testing practices.
- Caesar Cipher: Simple substitution cipher shifting character Unicode scalar values. Supports large and negative shift boundaries.
- Vigenère Cipher: Polyalphabetic substitution cipher using a key phrase to shift letters dynamically.
- XOR Cipher: Bitwise symmetric encryption mapping data bytes against a secret key using the XOR (
^) operator, outputted in standard Base64 format.
- Huffman Coding: A frequency-based frequency-sorted binary tree algorithm. It builds an optimal prefix tree (Huffman Tree) for the input text, generates variable-length bit codes, and compresses text into a binary stream.
- LZW (Lempel-Ziv-Welch): A dictionary-based compression algorithm that dynamically builds a translation table as it reads data, converting repeating patterns into integer codes.
- A interactive terminal menu allowing you to input custom text strings and immediately see the compression/encryption ratios, key outputs, and verification checks.
- Built with Apple's modern Swift Testing framework, including edge cases (boundary checks, large shifts, negative shifts, binary-only check, and full string reconstruction).
- macOS 14.0+ / Linux
- Swift 6.0+ / Xcode 15.0+
To clone and run this project locally:
# Clone the repository
git clone https://github.com/ChiefVenzox/SwiftCryptEngine.git
# Navigate into the project folder
cd SwiftCryptEngineBuild and run the interactive suite directly from the command line:
swift runVerify correctness of the cryptographic and compression engines:
swift testSources/
└── SwiftCryptEngine/
├── SwiftCryptEngine.swift # CLI Entry Point & Interactive Menu
├── Ciphers.swift # Caesar & Vigenère Implementations
├── XORCipher.swift # Bitwise XOR Encryption
├── HuffmanCoding.swift # Binary tree-based Huffman Compression
└── LZW.swift # Dictionary-based LZW Compression
Tests/
└── SwiftCryptEngineTests/
└── SwiftCryptEngineTests.swift # Modern Unit Tests using Swift Testing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
This project is licensed under the MIT License.