Hi Julia community!
I’m excited to share a new package I’ve been working on: ClassicCiphers.jl. This package was inspired by my experience solving some introduction cryptography challenges on Hackropole, a French CTF platform by ANSSI and some other beginners CTF about cryptography.
Package Overview
ClassicCiphers.jl provides implementations of classical cryptographic ciphers with a focus on:
- Clean, idiomatic Julia code
- Flexible configuration options
- Educational value for learning about historical cryptography
- Useful tools for CTF challenges and cryptography education
Features
Supported Ciphers
- Caesar Cipher (with configurable shift)
- ROT13 (special case of Caesar with shift=13)
- Affine cipher
- XOR cipher
- General Substitution Cipher
- Vigenère Cipher
- Vernam Cipher
Key Features
- Configurable alphabet handling
- Case sensitivity options
- Case preservation modes
- Custom symbol handling
- Built-in cipher inversion (encryption/decryption)
Usage Examples
Basic Caesar Cipher
using ClassicCiphers
# Create a Caesar cipher with default shift (3)
cipher = CaesarCipher()
plaintext = "HELLO"
ciphertext = cipher(plaintext) # Returns "KHOOR"
# Decrypt using inverse cipher
decipher = inv(cipher)
recovered_plaintext = decipher(ciphertext) # Returns "HELLO"
# Custom shift value
cipher = CaesarCipher(shift=5)
Vigenère Cipher with Custom Settings
# Encryption with a keyword
cipher = VigenereCipher("SECRET")
plaintext = "HELLO WORLD"
ciphertext = cipher(plaintext) # Returns "ZINCS PGVNU"
# Decryption
decipher = inv(cipher)
recovered_plaintext = decipher(ciphertext) # Returns "HELLO WORLD"
Customizable Behavior
# Configure case sensitivity and symbol handling
params = AlphabetParameters(
case_sensitivity=CASE_SENSITIVE,
output_case_mode=DEFAULT_CASE,
unknown_symbol_handling=REPLACE_SYMBOL
)
cipher = CaesarCipher(shift=5, alphabet_params=params)
Unique Features
-
Trait-based Design: The package uses Julia’s type system to handle different aspects of cipher behavior:
- Input case handling
- Output case preservation
- Unknown symbol handling
-
Consistent API: All ciphers follow the same pattern:
- Constructor for configuration
- Function call syntax for encryption
inv()
for creating decryption ciphers
-
Educational Value: Clear implementations make it easy to understand how classical ciphers work
Feedback Welcome!
I’d love to hear from the community about:
- Additional cipher implementations you’d like to see (modern ciphers are out of the scope of this package)
- Feature suggestions
- Use cases in education or CTF challenges
- Code improvements and optimizations
Future Plans
- Add more classical ciphers (Playfair, Hill cipher, etc.)
- Implement cipher analysis tools (maybe in an other package)
- Add visualization helpers for educational purposes
- Create documentation with interactive examples
Get Started
using Pkg
Pkg.add(url="https://github.com/s-celles/ClassicCiphers.jl")
Looking forward to your feedback and contributions!
Best regards
PS : I’m also open to transfer ownership to JuliaCrypto · GitHub
Pinging @staticfloat @StefanKarpinski @ViralBShah @sloede @oxinabox @aminya
PS2 : Doc is now available at Home · ClassicCiphers.jl