##language:zh #pragma section-numbers off ##含有章节索引导航的 ZPyUG 文章通用模板 <> ## 默许导航,请保留 <> = 如何加密python代码 = {{{ 王盈 aislsx@gmail.com 发件人当地时间 发送时间 08:09 (GMT+08:00)。发送地当前时间:上午8:19。 ✆ 回复 python-cn@googlegroups.com 发送至 python-cn@googlegroups.com 日期 2011年7月20日 上午8:09 主题 Re: [CPyUG] Re: 如何加密python代码? }}} ##startInc 这几天也碰到类似的问题。需要实现不能自由拷贝,锁定在特定计算机上运行。 我用的方法是:cython + mingw32 + VMProtect 用cython把.py的python源文件转换成C然后修改这个C的源程序, 加入 {{{ #include "VMProtectSDK.h" VMProtectBeginUltra("xxx"); VMProtectGetCurrentHWID(hwid_buf,100); .... }}} 等用于保护和硬件特征的校验代码。 然后再用mingw32编译, {{{ c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python26\include -IC:\Python26\PC -c hello.c -o build\temp.win32-2.6\Release\hello.o c:\mingw\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.6\Release\hello.o build\temp.win32-2.6\Release\hello.def -LC:\Python26\libs -LC:\Python26\PCbuild -lpython26 -lmsvcr90 VMProtectSDK32.lib -o hello.pyd }}} 最后用VMProtect加壳处理,让VMProtectGetCurrentHWID等函数生效。 请大家批评指正! 违背了开源精神,我有罪! ##endInc ---- '''反馈''' 创建 by -- ZoomQuiet [<>]