A secure file encryption/decryption tool based on modern cryptographic standards, featuring AES-256-CBC encryption algorithm and Argon2id key derivation function. Supports file and directory encryption with password confirmation mechanism to ensure encryption security.
# 安装依赖
pip install -r requirements.txt
# 运行程序
python3 main.py
# 查看帮助
python3 main.py --help
配置后可在任意目录运行:
# 一键配置脚本(推荐)
bash scripts/setup_path.sh
# 或者手动配置:
# 需要管理员权限
sudo ln -sf "$(pwd)/hycrypt" /usr/local/bin/hycrypt
# 或者用户目录(无需管理员权限)
mkdir -p ~/bin
ln -sf "$(pwd)/hycrypt" ~/bin/hycrypt
# 现在可以在任意目录运行
hycrypt --help
- Dual Operation Modes: Supports both interactive interface and command-line parameters
- Secure Encryption: Uses industry-standard AES-256-CBC encryption algorithm
- Strong Key Derivation: Utilizes Argon2id (winner of 2015 Password Hashing Competition)
- Smart File Naming: Automatically restores original filename after decryption, no extra suffixes
- Directory Encryption: Supports directory compression encryption with automatic multi-level subdirectory handling
- Password Confirmation: Enforces double confirmation during encryption to prevent password input errors
- Algorithm Display: Real-time display of current encryption algorithm information
- Custom Output: Supports specifying encryption/decryption output filenames
- File Integrity: Automatically handles file size and format
- Key Derivation: Derives 256-bit encryption key from user password using Argon2id
- Random Parameter Generation: Generates 128-bit random salt and initialization vector (IV)
- Preprocessing Check: If it's a directory, compresses it to ZIP format first
- AES Encryption: Encrypts file content using AES-256-CBC mode
- Data Assembly: Combines salt, IV, and ciphertext into encrypted file
- Post-processing: Cleans up temporary compression files (for directory encryption)
- Parameter Extraction: Extracts salt, IV, and ciphertext from encrypted file
- Key Reconstruction: Re-derives decryption key using same Argon2id parameters
- AES Decryption: Decrypts ciphertext using AES-256-CBC mode
- Data Recovery: Removes padding and restores original file content
- Post-processing: If it's a compressed file, automatically decompresses and restores directory structure
- Forward Secrecy: Uses random salt and IV for each encryption
- Password Verification: Naturally verifies password correctness through decryption results
- Password Confirmation: Enforces double confirmation during encryption to prevent password input errors
- Data Integrity: PKCS#7 padding ensures data integrity
- No Password Storage: System does not store user passwords, fully decentralized
- Algorithm Transparency: Real-time display of encryption algorithm information used
- Key Length: 256 bits, providing military-grade security strength
- Encryption Mode: CBC (Cipher Block Chaining), enhanced security
- Block Size: 128 bits, compliant with industrial standards
- Padding Scheme: PKCS#7, ensures data integrity
- Memory Consumption: 64MB, resistant to hardware attacks
- Time Cost: 10 iterations, balancing security and performance
- Parallelism: 4 threads, fully utilizing multi-core processors
- Salt: 128-bit random number, preventing rainbow table attacks
python encrypt.py
# Basic file encryption
python encrypt.py -e file.txt -p password
# Specify output filename
python encrypt.py -e file.txt -p password -o custom_name.enc
# Directory encryption (automatic compression)
python encrypt.py -e directory_path -p password
# Basic file decryption
python encrypt.py -d file.txt.enc -p password
# Specify output filename
python encrypt.py -d file.txt.enc -p password -o restored_file.txt
# Directory decryption (automatic decompression)
python encrypt.py -d 20250923-directory.zip.enc -p password
Feature | Description |
---|---|
Encryption Algorithm | AES-256-CBC |
Key Derivation | Argon2id |
Key Length | 256 bits |
Salt Length | 128 bits |
IV Length | 128 bits |
File Format | Supports any file type |
Directory Encryption | Automatically compresses multi-level directories |
Password Confirmation | Enforces double confirmation mechanism |
Algorithm Display | Real-time display of encryption algorithm |
Large File Handling | Supports large file streaming processing |
Run comprehensive test suite:
python run_tests.py
Tests include:
- ✅ Basic encryption/decryption functionality
- ✅ Command-line interface testing
- ✅ Error handling mechanisms
- ✅ Parameter validation
- ✅ Incorrect password handling
- ✅ Large file processing
- ✅ Interactive interface testing
- ✅ Directory encryption/decryption functionality (multi-level)
- ✅ Password confirmation mechanism
- ✅ Algorithm information display
encrypt.py # Main program file
test_integrated.py # Comprehensive test suite
run_tests.py # Test runner
__demo__/ # Demo directory (test only)
.claude/FILING_RULES.md # File management rules
README.md # This document
- User Files: Encrypted/decrypted files remain in original directory location
- Test Files: All test files are stored in
__demo__
directory - Directory Encryption: Compressed files are generated in same-level location as original directory
- Naming Format: Directory encryption uses
YYYYMMDD-directory_name.zip.enc
format
- User encrypted files are directly output to source file directory
- Test and demo files are uniformly placed in
__demo__
directory - Temporary compressed files are automatically cleaned up to maintain directory cleanliness
- Password Strength: Recommended password length of at least 6 characters
- Password Confirmation: Enforces double confirmation during encryption to prevent password input errors
- File Backup: Please backup important files before encryption
- Password Management: Please keep encryption passwords safe; forgotten passwords cannot recover files
- Encryption Verification: Please verify file integrity after encryption
- Algorithm Transparency: Real-time display of encryption algorithms used ensures security visibility
- Personal File Protection: Protect sensitive documents, photos and other personal privacy
- Directory Encryption: Batch encrypt entire folders including all subdirectories
- Data Transfer: Secure transfer of important files
- Backup Encryption: Encrypt backup files for protection
- Work Documents: Protect business secrets and work files
- Project Archiving: Encrypt entire project directories for secure storage
The encryption scheme implemented in this tool complies with the following international standards:
- AES: FIPS PUB 197 standard
- PBKDF2: RFC 2898 standard
- Argon2: PHC (Password Hashing Competition) standard