use:
pyarmor obfuscate main.py
Reference: Python code encryption scheme_python encryption code_wgr_1009's blog-CSDN blog
a brief introduction
PyArmor is a tool for protecting Python code. It can compile Python scripts into encrypted bytecodes to increase code protection. Its main purpose is to prevent unauthorized access, copying or modification of your Python code. Using PyArmor, you can convert your Python code into an unreadable form of bytecode, and require an authorization file at runtime to decrypt and run it. This helps prevent normal users from directly viewing your source code, but be aware that this does not prevent all possible attacks.
Interpretation of Zhihu: Research on the Principle of PyArmor - Zhihu
github: GitHub - dashingsoft/pyarmor
two use
Enter the directory to be encrypted, assuming main.py is the file to be encrypted. but
pyarmor obfuscate main.py
PyArmor will encrypt all files main.py
in the same directory as :*.py
and create the output subdirectory dist
之后按加密前的调用方法使用即可。
2.1 installation
pip install pyarmor
# 验证是否安装成功, 7.0 以下版本为稳定版
pyarmor --version