Split your files into encrypted fragments without needing all fragments for reconstruction!
Project description
๐ฎ Horcrux
Split your files into encrypted fragments using Shamir's Secret Sharing Scheme. No passwords to remember. Just keep your horcruxes safe :)
Horcrux is a file encryption and splitting tool that divides your sensitive files into multiple encrypted fragments (horcruxes). You can configure it so that only a subset of these fragments is needed to reconstruct the original file, providing both security and redundancy.
โจ Features
- ๐ Secure Encryption: AES-256-GCM encryption for your files
- ๐งฉ Threshold Scheme: Split into N parts, require only K parts to reconstruct
- ๐ฏ No Passwords: No need to remember complex passphrases years later
- ๐ฆ Easy Distribution: Spread horcruxes across multiple locations/media
- ๐ Simple CLI: Intuitive command-line interface
- ๐จ Interactive Mode: Beautiful GUI-like interface for non-technical users
- ๐ Cross-platform: Works on Windows, macOS, and Linux
- ๐ Metadata Preservation: Maintains original filename and timestamp information
๐ Table of Contents
- Installation
- Quick Start
- Usage
- How It Works
- Use Cases
- API Documentation
- Development
- Contributing
- License
- Acknowledgments
๐ฆ Installation
Via pip (Recommended)
pip install hrcx
Via pipx (Isolated)
pipx install hrcx
From Source
git clone https://github.com/juliuspleunes4/horcrux.git
cd horcrux
pip install -e .
๐ Quick Start
Split a File
# Split diary.txt into 5 horcruxes (any 3 required to reconstruct)
hrcx split diary.txt -t 5 -k 3
# Output:
# โ Created diary_1_of_5.hrcx
# โ Created diary_2_of_5.hrcx
# โ Created diary_3_of_5.hrcx
# โ Created diary_4_of_5.hrcx
# โ Created diary_5_of_5.hrcx
Bind Horcruxes Back
# Reconstruct from horcruxes in current directory
hrcx bind
# Or specify a directory
hrcx bind ./horcruxes
# Output:
# โ Found 5 horcruxes
# โ Threshold met (3 required, 5 available)
# โ Successfully reconstructed: diary.txt
๐ Usage
Getting Help
# Show help for main command
hrcx --help
# Show help for split command
hrcx split --help
# Show help for bind command
hrcx bind --help
# Check version
hrcx --version
Split Command
Split a file into multiple encrypted horcruxes:
hrcx split <file> [options]
Options:
-t, --total <number>- Total number of horcruxes to create (default: prompts user)-k, --threshold <number>- Minimum horcruxes needed to reconstruct (default: prompts user)-o, --output <directory>- Output directory for horcruxes (default: current directory)
Examples:
# Interactive mode (prompts for total and threshold)
hrcx split secret.pdf
# Split into 7 parts, any 4 can reconstruct
hrcx split secret.pdf -t 7 -k 4
# Specify output directory
hrcx split secret.pdf -t 5 -k 3 -o ./vault
Bind Command
Reconstruct the original file from horcruxes:
hrcx bind [directory] [options]
Options:
-o, --output <file>- Output file path (default: original filename)-f, --force- Overwrite existing file without prompting
Examples:
# Bind horcruxes from current directory
hrcx bind
# Bind from specific directory
hrcx bind ./vault
# Force overwrite existing file
hrcx bind -f
# Specify output location
hrcx bind -o ./recovered/secret.pdf
Interactive Mode
For non-technical users, Horcrux offers a beautiful interactive mode with a guided wizard:
hrcx interactive
Features:
- ๐จ Beautiful ocean-blue ASCII art header
- ๐ฏ Step-by-step guided workflows
- ๐ Color-coded prompts (green for success, red for errors, yellow for warnings)
- โ Automatic validation of all inputs
- ๐ Smart file discovery and defaults
- ๐ Perform multiple operations in one session
Windows Users: Simply double-click the horcrux.bat file to launch interactive mode without opening a terminal!
Interactive mode walkthrough:
- Choose between Split or Bind operations
- Follow the color-coded prompts:
- Split: Select file โ Set total horcruxes โ Set threshold โ Choose output directory
- Bind: Select horcrux directory โ Confirm reconstruction โ Choose output location
- Review the summary and confirm
- Watch as your operation completes with visual feedback
Perfect for users who prefer a GUI-like experience or are new to command-line tools!
๐ฌ How It Works
Horcrux uses a combination of Shamir's Secret Sharing Scheme and AES-256-GCM encryption:
-
Key Generation: A random 256-bit encryption key is generated using a cryptographically secure random number generator
-
File Encryption: The original file is encrypted using AES-256 in GCM (Galois/Counter Mode) for authenticated encryption
-
Secret Sharing: The encryption key is split into N fragments using Shamir's Secret Sharing algorithm, configured so that any K fragments can reconstruct the key
-
Horcrux Creation: Each fragment is embedded in a horcrux file along with:
- Encrypted file data (distributed across all horcruxes)
- Metadata (original filename, timestamp, index, threshold)
- Key fragment for reconstruction
-
Reconstruction: When binding:
- Collect K or more horcruxes
- Reconstruct the encryption key using Shamir's algorithm
- Decrypt and reassemble the original file
Shamir's Secret Sharing
This cryptographic algorithm allows a secret (the encryption key) to be divided into N shares, where any K shares can reconstruct the secret, but K-1 shares reveal nothing about it. This is accomplished using polynomial interpolation over a finite field.
Mathematical Foundation:
- Generate a random polynomial of degree K-1 with the secret as the constant term
- Evaluate the polynomial at N different points to create N shares
- Any K shares can reconstruct the polynomial (and thus the secret) using Lagrange interpolation
๐ก Use Cases
Personal Use
- Sensitive Documents: Split personal records, tax documents, or legal papers
- Cryptocurrency Wallets: Distribute wallet backups across multiple secure locations
- Password Manager Databases: Add an extra layer of security to password vaults
- Photo Albums: Protect private photos from single-point compromise
Professional Use
- Distributed Backups: Store critical business data across multiple geographic locations
- Multi-party Access: Require collaboration from multiple parties to access sensitive information
- Secure Transmission: Send file fragments through different communication channels to prevent interception
- Disaster Recovery: Ensure data can be recovered even if some backup locations are compromised
Who This Is For
- People who need to encrypt sensitive files without remembering passwords years later
- Organizations requiring multi-party authorization for sensitive data access
- Users who want to distribute backups across multiple physical locations
- Anyone named Tom Riddle ๐
๐ API Documentation
Horcrux can also be used as a library in your Python projects:
Installation
pip install hrcx
Usage
from hrcx import split, bind
# Split a file
split(
file_path='./secret.txt',
total=5,
threshold=3,
output_dir='./horcruxes'
)
# Bind horcruxes
bind(
horcrux_paths=['./horcruxes/secret_1_of_5.hrcx', './horcruxes/secret_2_of_5.hrcx', './horcruxes/secret_3_of_5.hrcx'],
output_path='./recovered.txt'
)
API Reference
split(file_path: str, total: int, threshold: int, output_dir: Optional[str] = None) -> None
Splits a file into encrypted horcruxes.
Parameters:
file_path(str): Path to the file to splittotal(int): Total number of horcruxes to create (must be >= threshold)threshold(int): Minimum number of horcruxes needed to reconstruct (must be >= 2)output_dir(Optional[str]): Output directory for horcruxes (default: same directory as input file)
Raises:
FileNotFoundError: If the input file doesn't existValueError: If total < threshold or threshold < 2PermissionError: If unable to write to output directory
Example:
from hrcx import split
split('secret.pdf', total=7, threshold=4, output_dir='./vault')
bind(horcrux_paths: Optional[List[str]] = None, output_path: Optional[str] = None, overwrite: bool = False) -> None
Reconstructs the original file from horcruxes.
Parameters:
horcrux_paths(Optional[List[str]]): List of paths to horcrux files. If None, auto-discovers horcruxes in current directoryoutput_path(Optional[str]): Output file path (default: original filename from horcrux metadata)overwrite(bool): Whether to overwrite existing file without prompting (default: False)
Raises:
FileNotFoundError: If no horcrux files foundValueError: If insufficient horcruxes or incompatible horcruxes providedRuntimeError: If decryption fails or file integrity check fails
Example:
from hrcx import bind
# Auto-discover horcruxes in current directory
bind()
# Specify horcruxes explicitly
bind(
horcrux_paths=['./vault/secret_1_of_7.hrcx', './vault/secret_4_of_7.hrcx', './vault/secret_6_of_7.hrcx', './vault/secret_7_of_7.hrcx'],
output_path='./recovered.pdf',
overwrite=True
)
๐ Development
Prerequisites
- Python >= 3.8
- pip >= 21.0
Setup
# Clone the repository
git clone https://github.com/juliuspleunes4/horcrux.git
cd horcrux
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run linter
ruff check src/
# Format code
black src/ tests/
# Type checking
mypy src/
Project Structure
horcrux/
โโโ src/hrcx/
โ โโโ cli.py # Command-line interface
โ โโโ crypto/ # Encryption and key management
โ โโโ shamir/ # Shamir's Secret Sharing implementation
โ โโโ horcrux/ # Horcrux file handling
โ โโโ utils/ # Utility functions
โโโ tests/ # Test files
โโโ docs/ # Documentation
โโโ pyproject.toml # Package configuration
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=hrcx --cov-report=html
# Run specific test file
pytest tests/test_api.py
# Run with verbose output
pytest -v
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Guidelines
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please make sure to:
- Update tests as appropriate
- Follow the existing code style
- Update documentation for API changes
- Add entries to CHANGELOG.md
๐ Security
Reporting Vulnerabilities
If you discover a security vulnerability, please email security@example.com instead of using the issue tracker.
Security Considerations
- Horcruxes are encrypted with AES-256-GCM, providing strong confidentiality and authenticity
- The encryption key is generated using
crypto.randomBytes()for cryptographic security - Shamir's Secret Sharing is implemented over GF(256) using standard polynomial interpolation
- Each horcrux contains metadata in plaintext (filename, timestamp, indices) for convenience
- The threshold scheme ensures that K-1 horcruxes reveal no information about the original file
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
This project was inspired by and adapted from the excellent horcrux project by Jesse Duffield, originally written in Go. The core concepts, including the use of Shamir's Secret Sharing Scheme and the creative Harry Potter theming, are credited to the original project.
Original Project:
- Repository: jesseduffield/horcrux
- Author: Jesse Duffield
- License: MIT
Additional Credits:
- Shamir's Secret Sharing implementation adapted from Hashicorp Vault
- Inspired by the Harry Potter universe created by J.K. Rowling
Other Projects by Jesse Duffield
Check out Jesse's other amazing projects:
- Lazygit - Simple terminal UI for git commands
- Lazydocker - Terminal UI for Docker and docker-compose
- OK? Programming Language - An experimental programming language
๐ Support
- ๐ Bug Reports: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐ Documentation: Wiki
๐บ Roadmap
- GUI application for non-technical users
- Support for streaming large files
- Cloud storage integration (AWS S3, Google Drive, etc.)
- Mobile app (iOS/Android)
- Verification mode to check horcrux integrity
- Compression before encryption
- Custom encryption algorithms support
โ ๏ธ Disclaimer
This software is provided "as is" without warranty of any kind. While Horcrux uses industry-standard encryption and secret sharing algorithms, the security of your data ultimately depends on how you store and protect your horcruxes. Always keep backups of important data.
Made with โค๏ธ
If you find this project useful, please consider giving it a โญ๏ธ on GitHub!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hrcx-1.2.2.tar.gz.
File metadata
- Download URL: hrcx-1.2.2.tar.gz
- Upload date:
- Size: 36.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f133532521df3c394bc4b9729db9f112bb1e81d9342bd83fe01e3f0d09d9fe7c
|
|
| MD5 |
6785bddd8a2bb328c8337b9a10cddbb5
|
|
| BLAKE2b-256 |
db189d3c9b77527f18026842a5c0e0ee8f40b05e3c1c292e0cca0e7cd8ae1a3d
|
File details
Details for the file hrcx-1.2.2-py3-none-any.whl.
File metadata
- Download URL: hrcx-1.2.2-py3-none-any.whl
- Upload date:
- Size: 27.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f816b52f8ebb6f6f447e45532292698584d6125d26069cf8d880837edffa0bd5
|
|
| MD5 |
0b36deceb7c353698d49170d3c1c724d
|
|
| BLAKE2b-256 |
ca7d2b80990b41a6f6358f1553e041ed9939bf75ce4568e0b3ddfb148c2433c0
|