A command-line tool for vigenere brute force operations with custom alphabets and keys.
- Python 3.8+
- pip
Mac: brew install pipx && sudo pipx ensurepath
Linux: sudo apt install pipx or whatever you need, figure it out :)
Windows: py -m pip install --user pipx then pipx ensurepath
pipx install git+https://github.com/irebased/dachi.git
Try it:
dachi --help
- Vigenère Cipher: Classic and autokey variants with custom alphabets
- Brute Force Decryption: Try all possible keys up to a specified length
- Orchestrated Attacks: Test multiple alphabets and keys simultaneously
- Alphabet Generation: Create keyed alphabets from word lists
- Key Generation: Parse and manage key lists from files
- Extensible Architecture: Easy to add new ciphers and cryptographic operations
- Rich CLI Interface: Beautiful terminal output with progress indicators
- Type Safety: Full type hints and validation with Pydantic
- Comprehensive Testing: Unit and integration tests with high coverage
# Clone the repository
git clone https://github.com/yourusername/dachi.git
cd dachi
# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"# Install pre-commit hooks
pre-commit install
# Run tests
pytest
# Format code
black src/ tests/
isort src/ tests/
# Type checking
mypy src/
# Linting
flake8 src/ tests/# Encrypt with standard alphabet
dachi vigenere encrypt --key "SECRET" --text "HELLO WORLD"
# Decrypt with standard alphabet
dachi vigenere decrypt --key "SECRET" --text "ZINCS VGXCS"
# Use custom alphabet
dachi vigenere encrypt --key "KEY" --text "HELLO" --alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ"# Encrypt with autokey (key + plaintext)
dachi vigenere encrypt --key "SECRET" --text "HELLO WORLD" --autokey
# Decrypt with autokey
dachi vigenere decrypt --key "SECRET" --text "ZINCS VGXCS" --autokey# Use a custom alphabet with special characters
dachi vigenere encrypt --key "KEY" --text "Hello, World!" --alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()"
> **Note:** All input text is automatically converted to uppercase before processing. For example, `hello world` becomes `HELLO WORLD` internally. This ensures consistent encryption and decryption regardless of input case.
# Read from file
dachi vigenere encrypt --key "SECRET" --input-file message.txt --output-file encrypted.txt
# Interactive mode
dachi vigenere encrypt --key "SECRET" --interactive# Try all keys up to length 3
dachi vigenere brute-force --text "ZINCS VGXCS" --key-length 3
# Use autokey mode
dachi vigenere brute-force --text "ZINCS VGXCS" --key-length 3 --autokey
# Read from file and specify output directory
dachi vigenere brute-force --input-file encrypted.txt --key-length 4 --output-dir results
# Use custom alphabet
dachi vigenere brute-force --text "ZINCS VGXCS" --key-length 2 --alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ"# Generate alphabet from words in a file
dachi alphabet generate --input-file words.txt --output-file custom_alphabet.txt
# Use different base alphabet
dachi alphabet generate --input-file words.txt --base-alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"Input File Format: The file can contain words/phrases separated by:
- Commas:
SECRET, KEY, PASSWORD - Spaces:
SECRET KEY PASSWORD - Newlines:
SECRET KEY PASSWORD
# Generate one alphabet per word/phrase
dachi alphabet generate-multiple --input-file words.txt --output-dir alphabets/# Generate from comma-separated words
dachi alphabet generate-from-words --words "SECRET,KEY,PASSWORD" --output-file alphabet.txtThe orchestrator allows you to test multiple alphabets and keys simultaneously, perfect for cryptanalysis scenarios.
# Test all keys from a file against the standard alphabet
dachi vigenere orchestrate --text "ZINCS VGXCS" --keys-file keys.txt
# Test a single key against multiple alphabets
dachi vigenere orchestrate --text "ZINCS VGXCS" --key "SECRET" --alphabets-file alphabets.txt# Test all combinations of alphabets and keys
dachi vigenere orchestrate --text "ZINCS VGXCS" --alphabets-file alphabets.txt --keys-file keys.txt
# Use autokey mode
dachi vigenere orchestrate --text "ZINCS VGXCS" --keys-file keys.txt --autokey
# Specify output directory and filename
dachi vigenere orchestrate --text "ZINCS VGXCS" --keys-file keys.txt --output-dir results --base-filename attack_resultsAlphabets File: Each line contains a complete alphabet string
ABCDEFGHIJKLMNOPQRSTUVWXYZ
SECRETKEYABCDFGHIJLMNOPQUVWXYZ
CUSTOMALPHABET123
Keys File: Keys separated by commas, spaces, or newlines
SECRET, KEY, PASSWORD
SECRET
KEY
PASSWORD
-
Single Key, Multiple Alphabets: Test if a known key works with different alphabet arrangements
dachi vigenere orchestrate --text "ciphertext" --key "KNOWNKEY" --alphabets-file alphabets.txt
-
Multiple Keys, Single Alphabet: Try different keys against the standard alphabet
dachi vigenere orchestrate --text "ciphertext" --keys-file keys.txt -
All Combinations: Exhaustive testing of all key-alphabet combinations
dachi vigenere orchestrate --text "ciphertext" --alphabets-file alphabets.txt --keys-file keys.txt -
Autokey Analysis: Test autokey mode with various keys
dachi vigenere orchestrate --text "ciphertext" --keys-file keys.txt --autokey
The orchestrator and brute force commands generate multiple output formats:
- TXT: Human-readable summary with all results
- JSON: Structured data for programmatic analysis
- CSV: Tabular format for spreadsheet analysis
Files are saved in the specified output directory with descriptive names.
# Create a keyed alphabet from common words
echo "SECRET, KEY, PASSWORD" > words.txt
dachi alphabet generate --input-file words.txt --output-file custom_alphabet.txt
# Create a list of potential keys
echo "SECRET, KEY, PASSWORD, TEST, HELLO" > keys.txt
# Try to decrypt with custom alphabet and key list
dachi vigenere orchestrate --text "encrypted_message" --alphabets-file custom_alphabet.txt --keys-file keys.txt# Try all possible 3-letter keys
dachi vigenere brute-force --text "encrypted_message" --key-length 3 --output-dir attack_results
# Check results
ls attack_results/
# Output: brute_force_results.txt, brute_force_results.json, brute_force_results.csv# Create multiple alphabets from different word sets
echo "SECRET, KEY" > words1.txt
echo "PASSWORD, LOGIN" > words2.txt
echo "ADMIN, ROOT" > words3.txt
# Generate alphabets
dachi alphabet generate-multiple --input-file words1.txt --output-dir alphabets/
dachi alphabet generate-multiple --input-file words2.txt --output-dir alphabets/
dachi alphabet generate-multiple --input-file words3.txt --output-dir alphabets/
# Test all alphabets with a known key
dachi vigenere orchestrate --text "encrypted_message" --key "KNOWNKEY" --alphabets-file alphabets/alphabets.txt# Test autokey mode with various keys
echo "SECRET, KEY, PASSWORD" > keys.txt
dachi vigenere orchestrate --text "autokey_encrypted_message" --keys-file keys.txt --autokeyfrom dachi.ciphers.vigenere import VigenereCipher
from dachi.core.alphabet import Alphabet
# Create cipher with custom alphabet
alphabet = Alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
cipher = VigenereCipher(alphabet=alphabet)
# Encrypt
encrypted = cipher.encrypt("HELLO WORLD", "SECRET")
print(encrypted) # Output: ZINCS VGXCS
# Decrypt
decrypted = cipher.decrypt("ZINCS VGXCS", "SECRET")
print(decrypted) # Output: HELLO WORLD
# Autokey mode
cipher_autokey = VigenereCipher(alphabet=alphabet, autokey=True)
encrypted_ak = cipher_autokey.encrypt("HELLO WORLD", "SECRET")
# Brute force decryption
results = cipher.brute_force_decrypt("ZINCS VGXCS", 3)
print(f"Found {results['successful_decryptions']} successful decryptions")
# Alphabet generation
from dachi.utils.alphabet_generator import AlphabetGenerator
keyed_alphabet = AlphabetGenerator.generate_keyed_alphabet(["SECRET", "KEY"], "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
alphabet_obj = Alphabet(characters=keyed_alphabet)
# Key parsing
from dachi.utils.key_generator import parse_key_list
keys = parse_key_list("keys.txt")The project is built with strong abstraction layers for optimal extensibility:
dachi.core.alphabet: Alphabet management and validationdachi.core.cipher: Abstract base classes for all ciphersdachi.core.key: Key management and validationdachi.ciphers.vigenere: Vigenère cipher implementationdachi.cli: Command-line interface using Clickdachi.utils: Utility functions and helpersdachi.orchestrator: Orchestrated decryption across multiple alphabets and keysdachi.utils.alphabet_generator: Generate keyed alphabets from word listsdachi.utils.key_generator: Parse and manage key lists from filesdachi.utils.output_formatter: Format results to various output formats
To add a new cipher, inherit from the base cipher class:
from dachi.core.cipher import Cipher
from dachi.core.alphabet import Alphabet
class MyCipher(Cipher):
def __init__(self, alphabet: Alphabet):
super().__init__(alphabet)
def encrypt(self, plaintext: str, key: str) -> str:
# Implementation here
pass
def decrypt(self, ciphertext: str, key: str) -> str:
# Implementation here
passdachi/
├── src/
│ └── dachi/
│ ├── __init__.py
│ ├── cli.py # CLI entry point
│ ├── orchestrator.py # Orchestrated decryption
│ ├── core/ # Core abstractions
│ │ ├── __init__.py
│ │ ├── alphabet.py # Alphabet management
│ │ ├── cipher.py # Base cipher classes
│ │ └── key.py # Key management
│ ├── ciphers/ # Cipher implementations
│ │ ├── __init__.py
│ │ └── vigenere.py # Vigenère cipher
│ └── utils/ # Utilities
│ ├── __init__.py
│ ├── text.py # Text processing
│ ├── alphabet_generator.py # Alphabet generation
│ ├── key_generator.py # Key parsing
│ └── output_formatter.py # Output formatting
├── tests/ # Test suite
├── pyproject.toml # Project configuration
├── README.md # This file
└── .pre-commit-config.yaml # Pre-commit hooks
# Run all tests
pytest
# Run with coverage
pytest --cov=dachi --cov-report=html
# Run specific test file
pytest tests/test_vigenere.py
# Run with verbose output
pytest -v- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request