Python Source Code Encryption Tool - Enterprise-grade protection for your Python source code
Project description
STXDefender - Python Source Code Encryption Tool
STXDefender provides enterprise-grade protection for your Python source code using AES-256-GCM encryption. Safeguard your intellectual property with military-grade cryptography, license management, and flexible access control.
Features
- ๐ AES-256-GCM Encryption - Industry-standard authenticated encryption
- ๐ License Activation - Secure token-based activation system with online validation
- โฑ๏ธ Enforced Expiry (TTL) - Control access with customizable expiration times
- ๐ Custom Password Support - Use your own passwords or auto-generated secure keys
- ๐ Trial Mode - Test the tool with 24-hour encrypted file limits
- ๐ Direct Execution - Run encrypted
.pyefiles directly with Python - ๐ป Simple CLI - Intuitive commands:
activate,validate,encrypt - ๐ Web Dashboard - Manage licenses, tokens, and subscriptions through a modern web interface
Installation
Install from PyPI (Recommended)
pip install stxdefender
After installation, the stxdefender command will be available globally.
Install from Source
If you want to install from the source code:
# Navigate to project directory
cd "path/to/sourcedefender remake"
# Install in editable mode
pip install -e .
Quick Setup (Windows)
Automated setup with server:
-
Double-click
setup_and_run.bat- Installs all dependencies
- Sets up the CLI tool
- Starts the backend server
-
Or use
START.batfor a quick start (assumes dependencies are installed) -
Or use
INSTALL.batto just install dependencies without starting
Quick Setup (Linux/Mac)
chmod +x setup_and_run.sh
./setup_and_run.sh
Quick Start Guide
1. Start the Backend Server
If you installed from source and want to run your own server:
cd backend
python app.py
The server will start on http://localhost:5000
2. Create an Account
- Open your browser and go to
http://localhost:5000 - Click "Sign up" and create an account
- Log in to access the dashboard
3. Generate an Activation Token
- In the dashboard, click "Generate New Token"
- Copy the token (you'll only see it once!)
4. Activate STXDefender
stxdefender activate --token YOUR_TOKEN_HERE
5. Validate Activation
stxdefender validate
6. Encrypt Your Python Files
# Basic encryption
stxdefender encrypt myapp.py
# With expiration (24 hours)
stxdefender encrypt --ttl=24h myapp.py
# With custom password
stxdefender encrypt --password=mysupersecret myapp.py
# Remove original file after encryption
stxdefender encrypt --remove myapp.py
This creates an encrypted .pye file (e.g., myapp.pye).
7. Run Encrypted Files
# Run encrypted file directly
python myapp.pye
# With custom password (if used during encryption)
export STXDEFENDER_PASSWORD="mysupersecret"
python myapp.pye
# On Unix/Linux/Mac, make executable and run directly
chmod +x myapp.pye
./myapp.pye
Command Reference
stxdefender activate --token <token>
Activate your license with a token obtained from the dashboard.
stxdefender activate --token 470a7f2e76ac11eb94390242ac130002
stxdefender validate
Check your current license activation status.
stxdefender validate
stxdefender encrypt [options] <file>
Encrypt a Python source file.
Options:
--remove- Remove the original file after encryption--ttl=<time>- Set expiration time (e.g.,24h,7d,30m,1w)--password=<pass>- Use a custom password (otherwise auto-generated)
Examples:
# Basic encryption
stxdefender encrypt script.py
# With 24-hour expiration and remove original
stxdefender encrypt --remove --ttl=24h myapp.py
# With custom password
stxdefender encrypt --password=mysecret script.py
# Complex example
stxdefender encrypt --remove --ttl=7d --password=supersecret myapp.py
TTL (Time To Live) Format
The --ttl option accepts the following formats:
30s- 30 seconds5m- 5 minutes24h- 24 hours7d- 7 days2w- 2 weeks365- 365 seconds (numeric only = seconds)
Password Handling
Auto-generated Password
If no password is specified, STXDefender generates a secure random password. This password is embedded in the encrypted file, making the file self-contained and ready to run.
Custom Password
You can specify a custom password during encryption:
stxdefender encrypt --password=mypassword script.py
When running the encrypted file, set the password as an environment variable:
# Unix/Linux/Mac
export STXDEFENDER_PASSWORD="mypassword"
python script.pye
# Windows (Command Prompt)
set STXDEFENDER_PASSWORD=mypassword
python script.pye
# Windows (PowerShell)
$env:STXDEFENDER_PASSWORD="mypassword"
python script.pye
If the environment variable is not set, it will use the password embedded in the file (or the one you specified during encryption).
Trial Mode
Without a valid license activation, STXDefender operates in trial mode:
- โ Encryption works normally
- โ ๏ธ Maximum TTL is limited to 24 hours
- โ ๏ธ A warning message is displayed
To remove trial limitations, activate with a valid token from the dashboard.
Project Structure
.
โโโ backend/
โ โโโ app.py # Flask backend API
โโโ frontend/
โ โโโ index.html # Landing page
โ โโโ login.html # Login/signup page
โ โโโ dashboard.html # User dashboard
โ โโโ admin.html # Admin dashboard
โ โโโ static/
โ โโโ style.css # Styles
โ โโโ auth.js # Auth page JavaScript
โ โโโ dashboard.js # Dashboard JavaScript
โ โโโ admin.js # Admin panel JavaScript
โโโ stxdefender.py # Main CLI tool
โโโ requirements.txt # Python dependencies
โโโ setup.py # Package setup for PyPI
โโโ README.md # This file
Development
Running the Backend
Windows:
- Use
setup_and_run.bat(installs and runs) - Use
START.bat(quick start) - Use
run_server.bat(assumes dependencies installed)
Linux/Mac:
./setup_and_run.sh
# OR
cd backend
python3 app.py
The server runs on http://localhost:5000 by default.
Environment Variables
STXDEFENDER_API_URL- API endpoint URL (default:http://localhost:5000)SECRET_KEY- Flask secret key (default: auto-generated)STXDEFENDER_PASSWORD- Default password for encrypted files
Database
The backend uses SQLite by default (jsdefender.db for compatibility). For production deployments, consider using PostgreSQL or MySQL.
Security
STXDefender implements multiple layers of security:
- Strong Encryption: AES-256-GCM authenticated encryption prevents tampering
- Key Derivation: PBKDF2 with 200,000 iterations for key generation
- Secure Tokens: Cryptographically secure random token generation
- License Binding: System fingerprinting binds licenses to specific machines
- Dual Validation: Both local and remote license validation
- Password Security: Passwords are hashed using SHA-256 (bcrypt recommended for production)
Use Cases
- Protect proprietary Python applications
- Distribute encrypted scripts with expiration dates
- Control access to sensitive code
- License management for commercial software
- Secure distribution of Python tools and utilities
License
This project is provided as-is for educational and development purposes.
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
Support
For issues and questions, please open an issue on the project repository.
Project details
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 stxdefender-1.0.1.tar.gz.
File metadata
- Download URL: stxdefender-1.0.1.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c2c14cd94ceed1887198f8108fa30be50c641988841ee51ff21445d18974e94
|
|
| MD5 |
c50bc19e144cf6e66a8d1a7a6c976c56
|
|
| BLAKE2b-256 |
fa81cbf96b1cbbe263ae0d3c792f12a19cf18723a124584072b15d1dfaa11ee4
|
File details
Details for the file stxdefender-1.0.1-py3-none-any.whl.
File metadata
- Download URL: stxdefender-1.0.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82f569d7760f0805a878fcb8fdc2c0e6a4937d1ba4aad45c8319407801d6ca05
|
|
| MD5 |
7087009b4a830747bc4944c324c8bb97
|
|
| BLAKE2b-256 |
f74ddb2791ed1c06b02a70f4ad8c428626f5cf6a509e374a8b67679c7fcae197
|