pyobfus
Modern Python Code Obfuscator
An open-source PyArmor alternative for teams that need to obfuscate before shipping without giving up production debugging. pyobfus emits portable Python through AST transformations and can reverse-map protected stack traces back to original identifiers for developers and AI coding assistants. Supports Python 3.9 through 3.14.
Features
๐ Community Edition (Free)
- Name Obfuscation: Rename variables, functions, and classes to I0, I1, I2...
- Comment Removal: Strip comments and docstrings
- String Encoding: Base64 encoding for string literals
- Numeric / Constant Obfuscation (
--numeric-obfuscation): replace integer/float literals with value-preserving opaque expressions - AI Provenance Stripping (
--strip-ai-artifacts): removeGenerated by Claude/Co-Authored-Bymarkers from docstrings and attribution dunders - Incremental Builds (
--incremental): skip a directory rebuild when inputs and config are unchanged - Multi-file Support: Obfuscate entire projects
- Reverse Stack-Trace Mapping (
--unmap): translate an obfuscated production traceback back to original names, so you (or an AI assistant) can debug shipped code without un-obfuscating it - Pre-flight Risk Check (
--check): flagseval/exec, dynamic attribute access, framework reflection, declared dependencies that do not resolve on public PyPI, and (for hardened Python 3.14+ deployments) PEP 768 remote-debug exposure — config-aware, JSON output, and--sarifexport for GitHub Code Scanning - YAML Configuration: Flexible configuration system
- Parameter Preservation: Keep function parameter names for keyword arguments
- Build Provenance: Local provenance manifest with hashes and CycloneDX-compatible relationships;
--verify-provenance-manifestvalidates it - Structured Dry-Run Plan & Syntax Verification (v0.5.19):
--dry-run --jsonpreviews a versioned plan;--verify-syntaxcompiles generated output in memory after a build (no import, no execution)
๐ Professional Edition - $45 USD
- โจ All Community Features +
- ๐ Control Flow Flattening: Transform code structure into state machines
- ๐งฉ Dead Code Injection: Inject unreachable code to increase complexity
- ๐ AES-256 String Encryption: Military-grade encryption for strings
- ๐ก๏ธ Anti-Debugging Checks: Detect and prevent debugging attempts
- ๐ License Embedding: Expiration dates, machine binding, run limits
- ๐งฑ v0.5 build-fusion mechanisms (compose via
pyobfus SRC -o OUT --level pro --<flag>): Selective Opacity, Seal-Code, String Vault, Scrub-Traceback, Fingerprint, Expire-Hard — plus run-counter cap, targeted opacity config, device-locked keys, and runtime import obfuscation - โก Configuration Presets: One-command setup (trial, commercial, library)
- ๐ Lifetime Updates: All future Pro features included
- ๐ป Up to 3 Devices: Use on multiple machines
- ๐ง Priority Email Support
๐ More purchase details โ
Installation
From PyPI (recommended):
pip install pyobfus
From source (for development):
git clone https://github.com/zhurong2020/pyobfus.git
cd pyobfus
pip install -e .
Quick Start
Obfuscate a single file:
pyobfus input.py -o output.py
Obfuscate a directory:
pyobfus src/ -o obfuscated/
With configuration:
pyobfus src/ -o obfuscated/ --config pyobfus.yaml
With an offline provenance manifest:
pyobfus src/ -o obfuscated/ --save-mapping mapping.json --provenance-manifest provenance.json
pyobfus --verify-provenance-manifest provenance.json --json
Example
Before obfuscation:
def calculate_total(price, quantity):
"""Calculate total price."""
tax_rate = 0.1
subtotal = price * quantity
tax = subtotal * tax_rate
return subtotal + tax
After obfuscation:
def I0(I1, I2):
I3 = 0.1
I4 = I1 * I2
I5 = I4 * I3
return I4 + I5
Note: Variable names may vary slightly, but functionality is preserved.
Documentation
- README - Full documentation
- Provenance Manifest - Obfuscated-output manifest fields and integrity notes
- Release Provenance - PyPI Integrity API and attestation verification runbook
- Current Plan - Current project status and priorities
- Changelog - Version history
- Security Policy - Report vulnerabilities
Community & Support
- GitHub Issues - Bug reports and feature requests
- GitHub Discussions - Questions and ideas
- Contributing - How to contribute
Purchase Professional Edition
๐ Professional Edition - $45 USD
One-time payment โข Lifetime access
๐ณ Pay by card, Apple Pay, or WeChat Pay (ๅพฎไฟกๆฏไป) for buyers in China โ Stripe shows the methods available for your region at checkout. Alipay (ๆฏไปๅฎ) is being enabled.
What's Included:
- โ Control Flow Flattening - State machine transformation
- โ Dead Code Injection - Increase code complexity
- โ AES-256 String Encryption
- โ Anti-Debugging Checks
- โ License Embedding - Expiration, machine binding, run limits
- โ Configuration Presets - One-command setup
- โ Lifetime Updates
- โ Up to 3 Devices
- โ Email Support (zhurong0525@gmail.com)
โก Instant delivery โข ๐ Secure checkout โข ๐ฏ 30-day money-back guarantee
Try Before You Buy
Want to test Pro features before purchasing? Use the 5-day free trial:
# Start a free trial (no registration, no credit card required)
pyobfus-trial start
# Quick start with presets
pyobfus src/ -o dist/ --preset commercial
# Or use individual features
pyobfus input.py -o output.py --control-flow --string-encryption --anti-debug --dead-code
# With license restrictions
pyobfus src/ -o dist/ --expire 2027-12-31 --bind-machine
# Check trial status
pyobfus-trial status
The trial includes all Pro features with full functionality for 5 days.
!!! note โThe trial is an honor-system controlโ
Trial state lives in an unsigned file in your home directory, and
pyobfus/trial.py ships as readable Apache-2.0 source, so the trial is a
convenience control rather than a security boundary. We document it that way
instead of claiming enforcement it cannot deliver โ see the
security policy.
The Community Edition has no file or line limits and requires no trial.
How to Purchase
Step 1: Click โBuy Nowโ and complete secure checkout (Stripe)
Step 2: Receive your license key via email within minutes
Step 3: Activate your license
pip install --upgrade pyobfus
pyobfus-license register PYOB-XXXX-XXXX-XXXX-XXXX
Activation Guide
Full activation instructions: License Activation Guide
Legal & Policies
By purchasing pyobfus Professional Edition, you agree to our:
- Terms of Service & EULA
- Refund Policy - 30-day money-back guarantee
- Privacy Policy - GDPR compliant
Security Note
String Encryption Limitations: AES-256 string encryption is designed as a deterrent against casual reverse engineering, not as cryptographic security. Because obfuscated code must decrypt strings at runtime, the encryption key is embedded in the output. This is a fundamental limitation of all client-side obfuscators.
Recommendation: For sensitive credentials (API keys, passwords), use environment variables or external secret management systems rather than embedding them in code.
See our full README for detailed security guidance.
License
Dual License Model:
- pyobfus (Core): Apache 2.0 - Free and open source
- pyobfus_pro (Pro): Proprietary - Requires paid license
Built with Python 3.9-3.14 โข AST-based Transformations โข Open Source