如何加密python源代码? [英] how to encrypt python source code?

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

问题描述

我们有一个用 Python 实现的关键业务程序.我们的老板不想让其他人,尤其是我们的竞争对手知道它是如何设计和实施的.所以我必须找到一种方法来加密它.我首先想到的是pyc和pyo,但很快我发现它们很可能会被反汇编.我想加密我们的源代码,但我不知道该怎么做?你们能帮我解决这个问题吗?任何指导将不胜感激.

we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled. I wanna encrypt our source codes, but i don't know how to do it? Could you guys please help me with this? Any guidance would be highly appreciated.

推荐答案

我建议你重新考虑这个问题,考虑:

I would suggest you go back into thinking about this, considering:

  • 为工作使用正确的工具
  • 混淆很难
  • 实现目标的其他方式

首先,Python 的设计目的不是混淆.该语言的每个方面都是免费的,任何想要检查或修改它的人都可以访问.作为一种字节码语言,很难锁定,而 Python 字节码很容易理解.如果您想构建内部看不到的东西,则必须使用其他工具.

Firstly, Python was not designed to be obfuscated. Every aspect of the language is free and accessible to anybody who wants to inspect or modify it. Being a bytecode language makes it difficult to lock down, and Python bytecode is easy to understand. If you want to build something you can't see inside, you will have to use another tool.

其次,一切(字面意思)最终都可以进行逆向工程,所以不要假设您能够完全保护任何一段代码.您必须能够理解隐藏一段代码的重要性(对于估计数量 X 的资源)与隐藏它的实际有用程度(也在工作量方面)之间的权衡.尝试并实际评估您的设计和实施"的重要性.真的是,为这一切辩护.

Secondly, everything (literally) can be reverse-engineered eventually, so do not assume you'll be able to fully protect any piece of code. You must be able to understand the tradeoff between the importance of hiding a piece of code (for an estimate amount X of resources) versus how useful hiding it actually is (also in terms of effort). Try and realistically evaluate how important your "design and implementation" really is, to justify all this.

考虑有法律要求.如果您预计人们会滥用您的代码,那么如果您能轻松发现滥用您的代码并将其转化为法律问题的人,也许会更有用.

Consider having legal requirements. If you expect people will misuse your code, maybe it would be more useful if you could easily discover the ones that do and turn this into a legal issue.

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

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