Python 代码的加密混淆

py 脚本编译成 c 文件(cython)

用 cython 将核心代码 py 模块文件转化成 .c 文件,再用 gcc 编译成 so(unix)文件,或者将其编译成 pyd(windows)文件。

编译过程:

1、服务器安装依赖

pip install python
yum install python-devel gcc

2、编写 setup.py 文件,内容如下:

from distutils.core import setup
from Cython.Build import cythonize
setup(
    ext_modules = cythonize("test.py",language_level=2)
)

# 批量编译
setup(
    ext_modules = cythonize(["test.py","test2.py".......],language_level=2)
)

3、运行以下命令

python setup.py build_ext --inplace
posted @ 2020-05-06 16:26  陈旭华  阅读(609)  评论(0编辑  收藏  举报