search

Home  >  Q&A  >  body text

怎样对 Python 源码加密?

PHP 可以使用 Zend Guard 对源码加密,然后发布使用。
想知道 Python 有没有类似的加密工具,加密后的代码仍然可以运行。

大家讲道理大家讲道理2767 days ago493

reply all(8)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 13:39:22

    Just publish the pyc file generated by compiling the python source code
    python -m py_compile src.py

    http://my.oschina.net/wizardpisces/blog/107445

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 13:39:22

    In fact, encryption is very simple. Modify the code of the Python virtual machine, modify the virtual code for the part where pyc is compiled, or swap a few. No one else can figure it out. This method comes from (Yunfeng Daxia) (from the book "My Programming Insights")
    The disadvantage is also obvious, you must use your own modified Python virtual machine when executing.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 13:39:22

    At best, it is just confusion. It is impossible to achieve encryption in the true sense. This is the nature of interpreted languages.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 13:39:22

    You can use this python obfuscator to encrypt.
    The encryption effect is irreversible, and other methods such as pyc, compiling into exe or even modifying the bytecode are easier to restore.

    reply
    0
  • 黄舟

    黄舟2017-04-17 13:39:22

    The most Python can do is obfuscate as mentioned above. If you want to encrypt the data, I haven’t found a good solution yet

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:39:22

    Compile the core code into an os file using cython (note: python syntax is still used).

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 13:39:22

    Finally someone has encountered this pitfall, haha

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:39:22

    pyminifier, and then compile it into pyc. Just provide pyc

    reply
    0
  • Cancelreply