Quick reference for developers working on the Cryptography Algorithm Toolkit.
- main.py - CLI menu dispatcher and package router
- Handles user input and delegates to algorithm modules
- Uses safe import wrapper to gracefully handle missing modules
Modules/
├── [Category]/
│ ├── [Sub-Category]/
│ │ ├── __init__.py (empty package marker)
│ │ └── algorithm.py (your implementation)
│ └── [Another Sub-Category]/
└── ...
| Function | Purpose |
|---|---|
_import() |
Safe module import with error handling |
_run() |
Execute algorithm menu with graceful fallback |
_get_choice() |
Get user input safely |
_clear() |
Clear screen (OS-aware) |
_header() |
Print formatted section header |
_menu_item() |
Format menu option display |
menu_symmetric() |
Category dispatcher (Symmetric) |
menu_asymmetric() |
Category dispatcher (Asymmetric) |
run_diagnostics() |
Check all 83 modules |
show_setup_guide() |
Auto-create init.py files |
Every algorithm must follow this structure:
"""
Algorithm Name Module
Implements: [Algorithm description]
Standard: [RFC/NIST/Academic reference]
Type: [Block Cipher / Hash / Signature / etc.]
Key Size: [e.g., 128/256 bits]
Security Level: [e.g., 128-bit]
"""
def algorithm_menu() -> None:
"""Main interactive menu for the algorithm."""
while True:
# Display options
# Get user choice
# Execute operation
# Handle back/exit
pass
# Helper functions
def _generate_key() -> str:
"""Generate cryptographic key."""
pass
def _operation(input_data: str, key: str) -> str:
"""Perform the cryptographic operation."""
pass# Create module file
touch Modules/Category/SubCategory/algorithm.py
# Implement algorithm with algorithm_menu() function
# Add to main.py
# Register in _ALL_MODULES list
# Test with verify_setup.py# Check syntax
python -m py_compile Modules/Category/algorithm.py
# Test import
python -c "from Modules.Category.algorithm import algorithm_menu"
# Run toolkit
python main.py
# Run diagnostics
python verify_setup.py# Launch toolkit
python main.py
# Navigate to your category
# Select your algorithm
# Test all menu options
# Verify no errorscryptography >= 42.0.0- NIST standardspycryptodome >= 3.20.0- Legacy algorithmsblake3 >= 1.0.0- BLAKE3 hashing
twofish- Twofish ciphertiger- Tiger hash (requires C++ tools)whirlpool- Whirlpool hash (requires C++ tools)
# Preferred: use cryptography library
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
# Fallback: use pycryptodome
from Crypto.Cipher import AES
from Crypto.Hash import SHA256
# Pure Python: implement yourself
import hashlib- Functions:
snake_case(e.g.,generate_key()) - Classes:
PascalCase(e.g.,CipherMode) - Constants:
UPPER_CASE(e.g.,BLOCK_SIZE = 128)
def function_name(param1: str, param2: int) -> bool:
"""
Brief one-line description.
Longer description if needed. Explain what the function does,
any important behavior, or edge cases.
Args:
param1: Description of param1
param2: Description of param2
Returns:
Description of return value
Raises:
ValueError: When X happens
TypeError: When Y happens
"""
passtry:
result = perform_operation(input_data)
print(f" ✅ Success: {result}")
except ValueError as e:
print(f" ❌ Invalid input: {e}")
except Exception as e:
print(f" ❌ Unexpected error: {e}")Before submitting a PR, verify:
- Module imports without errors
- Menu function exists and is named correctly
- All menu options work without crashing
- Error messages are user-friendly
- Back/exit options work correctly
- Type hints on all functions
- Docstrings on public functions
- No hardcoded paths or system dependencies
- Works on Windows, Linux, and macOS
-
verify_setup.pypasses -
main.pyruns without errors
Current state of the toolkit:
- Total Algorithms: 83+
- Categories: 9
- Python Files: 100+
- Test Coverage: Comprehensive
- Python Version: 3.10+
# Test direct import
python -c "from Modules.Category.algorithm import algorithm_menu"
# Check __init__.py exists
ls Modules/Category/__init__.py
# Verify package structure
python -m py_compile Modules/Category/algorithm.py# Run with debugging
python main.py # Navigate and check output
# Test function directly
python -c "from Modules.Category.algorithm import algorithm_menu; algorithm_menu()"# Check installed packages
pip list | grep cryptography
# Reinstall requirements
pip install -r requirements.txt --force-reinstall- Key Generation: Use
secretsmodule for cryptographic randomness - Input Validation: Always validate user input
- Error Messages: Don't leak sensitive information
- Dependencies: Use latest stable versions
- Best Practices: Follow NIST and RFC standards
mkdir -p Modules/New_Category/Sub_Category
touch Modules/New_Category/__init__.py
touch Modules/New_Category/Sub_Category/__init__.py# Add to category menu function
elif c == "1":
_run("Modules.Category.Sub_Category.algorithm",
"algorithm_menu", "Algorithm Name")
# Add to _ALL_MODULES list
_ALL_MODULES = [
("Modules.Category.Sub_Category.algorithm", "algorithm_menu"),
]def _header(title: str) -> None:
width = 64
print(f"\n{'═' * width}")
print(f" {title}")
print(f"{'═' * width}")
def _sub_header(title: str) -> None:
print(f"\n {'─' * 58}")
print(f" {title}")
print(f" {'─' * 58}")
def _menu_item(num: str, label: str, detail: str = "") -> None:
if detail:
print(f" {num:<4} {label:<38} {detail}")
else:
print(f" {num:<4} {label}")- Code Questions: Open a GitHub Discussion
- Bug Reports: File an Issue with details
- Feature Requests: Create an Enhancement issue
- Documentation: Check CONTRIBUTING.md
- Cryptography Library: https://cryptography.io/
- PyCryptodome: https://pycryptodome.readthedocs.io/
- NIST Standards: https://www.nist.gov/
- RFC Standards: https://www.ietf.org/rfc/
Happy coding! 🚀 If you have questions, feel free to ask in Discussions or Issues.