gpt4 book ai didi

python - 添加到 : How do I protect my Python codebase so that guests can't see certain modules but so it still works?

转载 作者:太空宇宙 更新时间:2023-11-04 10:57:10 25 4
gpt4 key购买 nike

How do I protect my Python codebase so that guests can't see certain modules but so it still works?

我的问题是上面页面上发布的附加问题。

如果有两个svn目录;例如,src/private 和 src/public 以及内部用户将同时拥有公共(public)目录和私有(private)目录,并且一切正常。

公共(public)用户将只有 src/public。是否可以在 init.py 中导入 src/private,即使用户没有 checkout 它?用户应该能够链接到它以解决 src/private 中的任何功能依赖性,但不应该能够查看文件的内容。

这个问题还有其他解决方案吗?

最佳答案

放弃吧。基本上不可能把好奇的眼睛挡在外面。例如,查看 dis模块:

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

这会产生:

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

瞧 - 有任何您想要隐藏的字符串,只需导入您的模块即可。还有其他模块和服务可以很好地将此类反汇编代码转换为可读的 Python 代码。

你到底想完成什么?也就是说,您具体要保护什么?

关于python - 添加到 : How do I protect my Python codebase so that guests can't see certain modules but so it still works?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8857950/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com