Welcome to the Mexican Army Cipher – a unique cryptographic tool inspired by historical cipher techniques, reimagined for modern Python enthusiasts. Whether you're a cryptography hobbyist, a developer exploring secure encoding, or a recruiter seeking creative coders, this project offers a fascinating blend of history, math, and programming. Let's dive in!
- Dynamic Alphabet Rotation: Start with any letter to shuffle the cipher's base alphabet.
- Multi-Ring Encryption: Encode messages across 4 configurable rings with custom offsets.
- Dual Output Modes: Choose between numeric codes or hybrid text/number representations.
- Randomized Encoding: Each character maps to multiple possible values for enhanced security.
- Simple API: Straightforward
encrypt()
anddecrypt()
methods for easy integration.
- Python 3.8+ (Core implementation)
- Random Module (For cryptographic operations)
- Git (Version control)
- PyCharm IDE (Development environment)
git clone https://github.com/JoeHitHard/MexicanArmyCipher.git
cd MexicanArmyCipher
### Basic Usage
```python
from mexican_army_cipher import MexicanArmyCipher
# Initialize cipher with custom parameters
cipher = MexicanArmyCipher(
start_letter='M', # Base alphabet rotation point
ring_offsets=[10,28,74,95],# Ring configuration
encode_to_text=False # Output format toggle
)
# Encrypt a message
plaintext = "Secret Message"
encrypted = cipher.encrypt(plaintext) # Returns "11-2-17-20-76-15-..."
# Decrypt back to original
decrypted = cipher.decrypt(encrypted) # Returns "secret message"
-
Secure Team Communication
Encode sensitive project codenames during development sprints. -
Educational Tool
Teach cryptography concepts with hands-on examples. -
API Key Obfuscation
Add an extra layer of protection for sensitive strings. -
Capture-the-Flag Challenges
Create engaging cybersecurity puzzles.
# encode_to_text=False
cipher = MexicanArmyCipher('M', [10,28,74,95], False)
print(cipher.encrypt("Hello")) # Output: "42-8-33-33-60"
# encode_to_text=True
cipher = MexicanArmyCipher('M', [10,28,74,95], True)
print(cipher.encrypt("Hello")) # Output: "1q-0h-1h-1h-2d"
-
Alphabet Rotation
The cipher starts by rotating the standard alphabet based on your chosen letter (e.g., 'M' → "mnopqrstuvwxyzabcdefghijkl"). -
Ring Configuration
Four encryption rings are created with offsets that determine their rotational positions. -
Randomized Mapping
Each plaintext character maps to multiple possible cipher values from different rings, chosen randomly during encryption.
Developed with ❤️ by Joseph Hit Hard
"In cryptography we trust, but we still verify!"