Python代码加密在线工具免费 ← 返回加密工具

About the Free Online Python Obfuscator

A free online Python code encryptor that runs in your browser. Paste your script, click encrypt, and get a protected .py file that is hard to read or tamper with but behaves exactly the same. No installs, no signup.

Two encryption modes

Both modes apply a lossless pre-obfuscation pass before compression and strip all Chinese comments and docstrings — even if someone unpacks the wrapper, they only see base64 gibberish, not your original logic.

Encryption levels: low / medium / high

Level controls how aggressively the output is compressed and unreadable. It does not affect correctness — high is the default and perfectly safe to run.

Batch encryption of a whole project

Upload a .zip to encrypt an entire Python project at once. Cross-file import names are kept consistent automatically (imported names are preserved, private file-level names are obfuscated), so you will not hit ImportError after encryption. Limits: 20MB zip, 500 files, 2MB per file.

Why "guaranteed to run" is not just marketing

  1. Syntax validation — the output is parsed with Python's ast right after obfuscation.
  2. Trial compilation — when a Python runtime is available on the server, the result is actually compiled with py_compile.
  3. Risk scanning — patterns the obfuscator cannot safely touch (exec/eval, globals() by string, **kwargs passthrough, dynamic imports) are detected, auto-handled or flagged.

Honest boundary: missing third-party libraries or OS-level environment problems are on your runtime, not on the obfuscator — no tool can fix those.

Privacy

Encryption runs in memory on the server and the data is discarded immediately. Nothing is stored, retained or logged. The serverless functions are stateless. For the most sensitive cases, self-host the open-source project on your own server.

What this tool is not for

It stops casual users — people who should not see your source see garbage instead. If you are defending against professional reverse engineers, you need commercial solutions like PyArmor (hardware binding, bytecode encryption, C extensions). This tool is deliberately simple: fast, free, and reliable.

· · · · · · · · · · · · · · · · · · · · · · · ·

Python 代码加密在线工具:关于与使用说明

这是一个免费的 Python 代码加密网站。你不需要安装任何软件,打开网页、把代码粘进去、点一下加密,就能拿到一份"普通人看不懂、但运行结果完全一样"的 Python 文件。下面把工具怎么用、能做什么、不能做什么,一次说清楚。

两种加密模式,按需选择

工具提供两种思路完全不同的加密方式:

两种模式下都会在压缩编码前先做一层"无损预混淆",并清除所有中文注释和中文 docstring——即使有人把封装解开还原,看到的也是一堆 base64 字符串和干扰代码,而不是你的原始逻辑。

加密级别:低 / 中 / 高

三个级别控制的是加密产物的"紧凑度与可读性":级别越高,压缩越狠,产物越难读。注意:级别不影响运行正确性——高等级只会让代码更不可读,不会引入运行风险。所以默认直接选"高"就行。

程序包模式:整个项目一次加密

单文件加密之外,工具支持上传 .zip 批量加密整个 Python 项目。跨文件 import 的名字会自动保持一致(被别的文件 import 的名字保留原名,文件内部私有名正常混淆),避免加密后出现 ImportError。加密完成后直接下载新的 zip。程序包的处理上限:zip 20MB、500 个文件、单文件 2MB。

"加密后保证可运行"是怎么保证的?

这是本工具和其他混淆器最大的区别,靠三层自动检查背书:

  1. 语法校验:加密后立即用 Python 的 ast 解析一遍,语法错了直接报出来,不会把坏文件交给你。
  2. 试编译验证:服务器有 Python 环境时,用 py_compile 实际编译产物,编译通过才算成功。
  3. 危险模式扫描:扫描 exec/eval、globals() 字符串访问、**kwargs 透传、动态导入这类混淆器碰不到的模式,自动规避或明确提示。

要说明白边界:第三方库是否安装、操作系统差异、运行环境问题,任何混淆器都管不了——这取决于你的运行环境,不是加密的锅。

隐私:你的代码会上传服务器吗?

加密处理发生在服务器端的内存里(单文件加密和程序包加密都是),处理完成立即丢弃,服务器不存储、不保留、不记录你的代码和程序包。Vercel 的 serverless 函数是无状态的,每次请求独立执行。对隐私要求极高的场景,建议你在自己的服务器上部署一套(项目是开源的)。

什么场景不适合这个工具?

说实话,它防的是"普通用户"——不想让你看到源码的人,看到的是乱码,改不了。但如果你面对的是专业逆向工程师,或者要防的是竞争对手长期对抗,需要的是 PyArmor 这类商业级方案(绑定硬件、加密字节码、C 扩展),不是在线工具能解决的。工具定位很清楚:快速、免费、保证能跑,让大多数场景够用。

常见问题