简体   繁体   English

如何保护 Python 源代码,同时使文件可供运行?

[英]How to protect Python source code, while making the file available for running?

So, I recently made a Python program that I want to send to someone with them being able to execute it, but not read the code I have typed in it.所以,我最近制作了一个 Python 程序,我想将它发送给能够执行它的人,但不能读取我输入的代码。 Any ideas how to do it?任何想法如何做到这一点?
BTW, I want it to be irreversible, except when reversed by me顺便说一句,我希望它是不可逆转的,除非被我逆转
In short, here are my Parameters:简而言之,这是我的参数:

  1. Should remain a Python file应该保留一个 Python 文件
  2. Can't be reversed, except by me无法逆转,除了我
  3. Code should not be readable代码不应该是可读的
  4. Should still have the ability to be run应该还是有能力跑的

The criteria you've posted are inconsistent.您发布的标准不一致。 Python is an interpreted language. Python 是一种解释型语言。 The entity running the language (ie Python interpreter) is reading your code and executing it, line by line.运行该语言的实体(即 Python 解释器)正在读取您的代码并逐行执行它。 If you wrap it up to send to someone, their Python interpreter must have read permissions on the file, whether it's source code or "compiled" Python (which is easily decompiled into equivalent source code).如果您将其打包发送给某人,则他们的 Python 解释器必须对该文件具有读取权限,无论是源代码还是“编译”的 Python(很容易反编译为等效的源代码)。

If we take a wider interpretation of "send to someone", there may be a business solution that serves your needs.如果我们对“发送给某人”进行更广泛的解释,那么可能有一种业务解决方案可以满足您的需求。 You would provide your functionality , rather than the code: deploy it as a service from some available server: your own, or rented space.你会提供您的功能,而不是代码:其部署为从一些提供服务器的服务:你自己的,还是租来的空间。 To do this, you instead provide an interface to your functionality.为此,您需要为您的功能提供一个接口

If this fulfills your needs, you now have your next research topic.如果这满足您的需求,您现在就有了下一个研究课题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM