[英]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.