如何在 Raspberry Pi 上保护我的 Python 脚本? [英] How to protect my Python scripts on Raspberry Pi?

查看:67
本文介绍了如何在 Raspberry Pi 上保护我的 Python 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Python 上开发了一个漫长而复杂的计算机视觉算法.我坚持冗长而复杂",因为我最后的解决方案是用 C++ 重写它(它大约有 3000 行,依赖于纯 Python 库)...

I have developed a long and complex computer vision algorithm on Python. I insist on the "long and complex" because my very last solution would be to rewrite it with C++ (it's about 3 000 lines long and depends on pure Python libraries)...

此算法嵌入在 Raspberry Pi A+ 上.可以将 SD 卡插入此纳米计算机,使其包含 Linux 系统.

This algorithm is embedded on a Raspberry Pi A+. It is possible to plug an SD card to this nanocomputer, so that it includes a Linux system.

所以基本上我的脚本在那个 SD 的文件夹中.当树莓派开机时,它运行系统,然后执行我的代码.

So basically my script is in a folder in that SD. When the Raspberry Pi is switched on, it runs the system and then executes my code.

假设有人取回了这张 SD 卡.我如何确定他将无法访问我的脚本?

Let's say someone retrieve this SD card. How can I be sure that he won't be able to get to my script ?

我读过很难混淆 Python 代码,它仍然如此吗?假设我会用荒谬的名字重命名我的所有变量,以扰乱轨道".有没有程序可以追溯整个算法的结构?

I've read it was difficult to obfuscate Python code, is it still true ? Let's say I would rename all of my variables with absurd names, to "scramble the tracks". Are there programs that can retrace the structure of the whole algorithm ?

关于 SD 卡本身,是否可以对其进行保护?我实际上在做的是在启动 Raspberry Pi 时停用 HDMI 和 USB 端口,并使用密码保护 SSH 连接.您认为这样就足够了,还是有人可以通过其他方式访问脚本?

Regarding the SD card itself, is it possible to protect it ? What I am actually doing is I deactivate the HDMI and USB port when the Raspberry Pi is launched, and protect the SSH connexion with a password. Do you think this is enough, or is there other ways someone can get to the script ?

最后,用 C++ 重写它......它可以确保我 100% 保护它吗?!

Finally, rewritting it in C++... Would it ensure me that it would be 100% protected ?!

先谢谢你.:)

推荐答案

我认为最好的解决方案是使用打包工具编译 Python 文件.

I think your best solution would be to compile your Python file using a bundling tool.

请参阅编译 Python 代码.

例如使用 PyInstaller

pip install pyinstaller
pyinstaller yourprogram.py

尽管您永远无法(即使使用 C++)保证完全保护".有诸如逆向工程之类的技术可用于揭示您的算法.

Although you can never (even with C++) guarantee full "protection". There are techniques like reverse engineering that can be used to reveal your algorithm.

这篇关于如何在 Raspberry Pi 上保护我的 Python 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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