Obfy
Obfy is a Python code-protection tool: it obfuscates your source, compiles it,
and encrypts the result behind a native loader so your .py never ships in
readable form. One command turns a Python package into a drop-in protected
distribution that runs exactly like the original.
Python obfuscation is deterrence, not encryption-grade security. CPython must eventually execute real bytecode, so a determined attacker who controls the runtime can recover code. Obfy stops casual copying and raises the cost for everyone else — it does not replace legal protection for sensitive IP.
What Obfy does
| Capability | What it means for you |
|---|---|
| AST obfuscation | Strips docstrings, mangles string literals, injects dead code, and renames identifiers — tuned by a single --level 0–5 dial. |
| Bytecode encryption | Each module is compiled, marshalled, and AES-256-GCM encrypted. A native import hook decrypts in memory at import time. |
| Native function compilation | At the highest level, eligible functions are lowered to a clean-room bytecode VM, so their CPython bytecode never ships at all. |
| Licensing | Optional expiry dates and machine binding, enforced by the loader at import time — no network calls. |
| Drop-in output | The protected dist mirrors your source tree 1:1. Run it, import it, or bundle it with PyInstaller with no path changes. |
Where to start
- New to Obfy? Read the Introduction for the core concepts.
- Ready to install? Follow the Installation guide.
- Want a hands-on walkthrough? Do the Tutorial.
- Looking for a specific task? Browse the Guides.