Caesar Cipher Encryption/Decryption
A comprehensive Caesar cipher implementation in Rust with both library and CLI functionality. Supports uppercase and lowercase letters with robust error handling.
Features
- ๐ Caesar cipher encryption and decryption
- ๐ค Both uppercase and lowercase letter support
- โก Fast and efficient implementation
- ๐ก๏ธ Safe functions with error handling
- ๐ป Command-line interface (CLI)
- ๐ File input/output support
- ๐ Brute force decryption
- ๐ฏ Interactive mode
- โ Comprehensive test coverage
Installation
Add this to your Cargo.toml:
[]
= "0.6.2"
Library Usage
Basic Usage
use ;
Safe Functions with Error Handling
use ;
Brute Force Decryption
use decrypt;
CLI Usage
Installation
Basic Commands
# Encrypt text
# Decrypt text
# Interactive mode
# Brute force decryption (try all shifts)
# Show help
File Operations
# Encrypt from file
# Decrypt from file
Safe Mode
# Use safe mode with error checking
Supported Characters
- Uppercase letters: A-Z
- Lowercase letters: a-z
- Other characters: Numbers, symbols, and non-ASCII characters remain unchanged
Examples
use *;
Testing
Run the comprehensive test suite:
Error Types
The library includes custom error types for better error handling:
CipherError::EmptyText: When input text is emptyCipherError::InvalidShift: When shift value is outside the valid range (-25 to 25)
Performance
This implementation is optimized for performance with:
- Zero-allocation character processing
- Efficient modular arithmetic
- Minimal bounds checking
Links
License
This project is licensed under the MIT License.