简体   繁体   English

添加到:如何保护我的Python代码库,以便访客无法查看某些模块,但仍然有效?

[英]Add on to: How do I protect my Python codebase so that guests can't see certain modules but so it still works?

How do I protect my Python codebase so that guests can't see certain modules but so it still works? 如何保护我的Python代码库,以便访客无法看到某些模块,但仍然有效?

My question is an add on question posted on the page above. 我的问题是上面页面上发布的添加问题。

If there are two svn directories; 如果有两个svn目录; for example, src/private and src/public and internal users will have both public and private directories and things will just work fine. 例如,src / private和src / public和内部用户将同时拥有公共和私有目录,事情就可以正常工作了。

The public users will have only src/public. 公共用户只有src / public。 Is it possible to import the src/private in init .py even though the user doesn't have it checked out? 是否可以在init .py中导入src / private,即使用户没有检出它? The user should be able to link to it to resolve any functional dependencies in src/private but, should not be able to view to content of the files. 用户应该能够链接到它以解决src / private中的任何功能依赖性,但是不应该能够查看文件的内容。

Are there any other solutions for this problem? 这个问题还有其他解决方案吗?

Give it up. 放弃。 It's essentially impossible to keep curious eyes out. 保持好奇的眼睛基本上是不可能的。 For instance, look at the dis module: 例如,看看dis模块:

import dis
def foo(): print 'bar'
dis.dis(foo)

which would yield: 会产生:

1           0 LOAD_CONST               1 ('bar')
              3 PRINT_ITEM          
              4 PRINT_NEWLINE       
              5 LOAD_CONST               0 (None)
              8 RETURN_VALUE

Voila - there are any strings you wanted to hide, simply by importing your modules. Voila - 只需导入模块,就可以隐藏任何字符串。 There are other modules and services that can do a pretty good job of converting such disassemblies into readable Python code. 还有其他模块和服务可以很好地将这些反汇编转换为可读的Python代码。

What exactly are you trying to accomplish? 你到底想要完成什么? That is, what specifically are you trying to protect? 那就是你要特别保护什么?

You can always move core functionality to some C or C++ module, and distribute only the compiled version of the module. 您始终可以将核心功能移动到某个C或C ++模块,并仅分发模块的编译版本。

See http://docs.python.org/extending/extending.html 请参阅http://docs.python.org/extending/extending.html

暂无
暂无

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

相关问题 如何保护我的Python代码库,以便访客无法看到某些模块,但仍然有效? - How do I protect my Python codebase so that guests can't see certain modules but so it still works? 如何编辑我的 VS Code 环境,以便我可以为我的 Python 代码预设输入数据,这样我就不必一次又一次地输入数据 - How do I edit my VS Code environment so that I can preset Input data for my Python Code so that I don't have to input data again and again 我可以将我的脚本/api 添加到我的 Django 项目中吗? 如果是这样,我该怎么做 - can I add my script/apis to my Django project? If so how can I do this 如何设置我的路径,以便它与作为 package 本地安装的 Python 代码一起使用 - How can I set my path so that it works with Python code that is locally installed as a package 如何在 Python 中引用一个目录,使其在多台计算机上工作? - How do I reference a directory in Python so it works on multiple computers? 如何重新启动我的 Python Arcade 游戏,以便在游戏结束后正常运行? - How can I restart my Python Arcade game so that it works properly after game over? Python:如何修复此代码,使其可在Windows上使用? - Python: How can I fix this code so it works on Windows? 如何配置python脚本的路径,以便可以使用cmd和python解释器打开它 - How do I configure the path of my python scripts so I can open it with cmd and python interpreter 如何将 tesseract 添加到我的 Docker 容器中,以便我可以使用 pytesseract - How do I add tesseract to my Docker container so i can use pytesseract 更改 Python 模块的权限,这样我就不需要“sudo”我的 Python 脚本调用 - Changing Permissions on Python Modules so I Don't Need to “sudo” My Python Script Calls
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM