编译加密 python

【编译加密方法】
1. 假设需要加密的脚本为gen_data.py ,其中含有一个main()方法。编写脚本 setup.py
#!/usr/bin/python3

from distutils.core import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("gen_data.py")
)


2. 执行./setup.py build_ext --inplace 
生成gen_data.cpython-35m-x86_64-linux-gnu.so和gen_data.c
gen_data.cpython-35m-x86_64-linux-gnu.so就是python代码加密后的so库

【使用方法】
1. 编写脚本run_gen_data.py
#!/usr/bin/python3
import sys
sys.path.append("./")
import gen_data

gen_data.main()

执行./run_gen_data.py

猜你喜欢

转载自blog.csdn.net/weixin_38740463/article/details/90022781