Affine Cipher CLI
Tuesday, September 15, 2026 at 2:31 AM | 1 min read
Last modified on Tuesday, September 15, 2026 at 2:31 AM
Photo by Tomas Martinez on unsplash.com
This project is a Python command-line implementation of the affine cipher, a classical substitution cipher where each letter is transformed by E(x) = (ax + b) mod 26 and reversed using the modular multiplicative inverse of a. It's built with uv, has a full test suite, and carries a thorough linting, type-checking, and security-scanning toolchain enforced through pre-commit hooks and GitHub Actions CI.
The CLI encrypts and decrypts text through encrypt/decrypt subcommands. Encryption requires an explicit key, validated to ensure it's mathematically accurate before it's used, so a bad key fails loudly instead of silently breaking the cipher. Decryption works either with a known key or by brute-forcing every valid key when the key isn't known. Both directions preserve each letter's original case and leave punctuation and spacing untouched.
