保护python源代码 [英] Protecting python source code

查看:234
本文介绍了保护python源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想保护python脚本,因为人们最有可能是混蛋并且偷了别人的作品,所以我真的很想保护它. 可悲的是,它很容易被盗...复制粘贴我花了几个月时间的作品,然后有人更改了部分内容并为自己索要.

I want to protect python script, since people most likely known to be jerks and steal someones work i would really like to protect it. Its sad how easily it can be stolen... copy paste my work that i spent months in and then someone changes bits and claims it for himself.

如何防止任何人看到代码? (我尝试过py2exe和类似的工具,但是由于它的.exe多数情况下对用户而言是可疑的,所以我不想让任何人担心我的软件)

How can i prevent anyone from seeing code? (i tried py2exe and similar, but that most often is suspicious to user since its .exe and i don't want anyone to be afraid of my software)

Linux Python2和Python3

Linux Python2 & Python3

推荐答案

加密python代码,并在导入时解密.

第1步-实施自己的模块加载器

您可以使用 importlib 来实现自己的python模块加载器.也就是说,您可以更改导入过程以解密加密的python代码.

Encrypt the python code and decrypt them when importing.

Step 1 - Implement your own module loader

You can use the importlib to implement your own python module loader. That is to say, you can change the import process to decrypt your encrypted python code.

但是您可能会说模块加载器也是用python编写的,可以在python脚本中轻松看到加密密钥.

But you may say the module loader is also written in python, the crypto key can be easily seen in the python script.

让我们继续下一步.

由于 cython ,python模块可以用C/C ++编写.解密代码将被编译为二进制代码.与py或pyc文件相比,很难进行反向工程.

Thanks to cython, python module can be written in C/C++. The decryption code will be compiled to binary code. That's very hard to reverse engineer compared to py or pyc files.

这是最简单的部分. :)

This is the simplest part. :)

这篇关于保护python源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆