Pyarmor, guard your python scripts
Pyarmor is a command line tool used to guard your python scripts.
There are 2 features:
- Protect python plain script by importing encrypted python scripts in
- runtime Convert python script to executable file
The former is implemented by python extension pyshield, the latter in module pyload function.
Download package as your python version list below, extract all files to any path.
http://dashingsoft.com/products/pyshield/windows/pyarmor-1.7.0-for-windows-python-2.3.zip#md5=13ec17ac5fccfa8bf7ade8d3605dfe15 http://dashingsoft.com/products/pyshield/windows/pyarmor-1.7.0-for-windows-python-2.4.zip#md5=73be9139ea54b9162a1aca471da4b895 http://dashingsoft.com/products/pyshield/windows/pyarmor-1.7.0-for-windows-python-2.5.zip#md5=75d134c0822d5c6e8a6d0c80099f47fb http://dashingsoft.com/products/pyshield/windows/pyarmor-1.7.0-for-windows-python-2.6.zip#md5=6f69175f0670ff49c3866aae753e7f51 http://dashingsoft.com/products/pyshield/windows/pyarmor-1.7.0-for-windows-python-2.7.zip#md5=a8f48e63932518eeb580bfbb89785327 http://dashingsoft.com/products/pyshield/windows/pyarmor-1.7.0-for-windows-python-3.0.zip#md5=4d54413dab6cab9a37e2d74e4004ae27 http://dashingsoft.com/products/pyshield/windows/pyarmor-1.7.0-for-windows-python-3.1.zip#md5=9df1b06490eb862bc612a388758b14fd http://dashingsoft.com/products/pyshield/windows/pyarmor-1.7.0-for-windows-python-3.2.zip#md5=756f829cf95bfa05e1b2fca081e66ed6 http://dashingsoft.com/products/pyshield/windows/pyarmor-1.7.0-for-windows-python-3.3.zip#md5=bb5fd437f0dface002bf549d2ab3c624
Download trial license and put into the same path
The main script is pyarmor.py
python pyarmor.py encrypt [OPTIONS] [File Patterns]
To encrpty the files list in the command line, you can use a specified pattern according to the rules used by the Unix shell. No tilde expansion is done, but *, ?, and character ranges expressed with  will be correctly matched.
All the files will be encrypted and saved as original file name plus x
-O, --output=DIR All the encrypted files will be saved here. If it's empty, the encrypted file will be saved in the original path. -K, --key=HEXDATA/FILENAME Used to encrypt scripts. It could be 32-bytes hex-data string, or a file which includes 32-bytes hex-data string.
pyarmor encrypt -K mytest.key a.py b.py
This command will encrypt a.py and b.py by the key in the file mytest.key, and save as a.pyx, b.pyx.
pyarmor encrypt -K mytest.key *.py src/*.py lib/*.pyc
This example showes how to use pattern to specify files.
pyarmor encrypt -K "00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F" \ "10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F" \ a.py
This example uses hex-data as encrypted key.
pyarmor encrypt -K mytest.key --output=dist/ *.py src/*.py lib/*.pyc
In this example encrypted files will be saved in the directory ‘dist’ other than the same path with the original script.
Convert Script To Executable File
python pyarmor.py convert [Options] [Scripts]
Convert script to binary file, and copy all the required file to outupt directory.
-K, --key=HEXDATA/FILENAME The key used to encrypt scripts. It could be 32-bytes hex-data string, or a file which includes 32-bytes hex-data string. -O, --output=DIR Default is dist/ --env=NAME:VALUE The environments used to run the script. you This option can be used for many times. (Not Implemented) -p, --pypath=PATH The extra python path used to run the script. This option can be used for many times. --exclude=PATTERN Exclude files, given as a shell-style PATTERN -n, --dry-run Do not realy copy python library files, only show what will do. It will spend a lot of time to copy python library files because there are so many files. So you can disable this action if you don't want to copy python library files. Note: even in dry-run mode, binary file will be generated.
python pyarmor convert -K mytest.key main.py
This command will convert main.py to an execute file main.exe, copy all the required file to dist/ .
python pyarmor convert -K mytest.key -O dist \ --env=PYTHONUNBUFFERD:1 --env=LD_LIBRARY_PATH:/home/jondy \ --pypath=C:\Python26\mylib --pypath=D:\Tcl\python\libs \ --exclude=*.pyc --exclude=site-packages --exclude=test \ main.py hello1.py
This command will convert main.py, hello.py to main.exe, hello.exe, and don’t copy compiled library files (*.pyc), don’t copy site-packages, don’t copy all the test module.
Note: The output path MUST NOT be in the sub-directory of any pyth path.
[Need to document]
Send an email to email@example.com, Thanks.
Read file pyshield.rst pyload.rst in the package.