Protect your python script, encrypt .pyc to .pye and decrypt when import it.
- your_script.py
import pyconcrete
- pyconcrete will hook import module
- when your script do
import MODULE
, pyconcrete import hook will try to findMODULE.pye
first and then decryptMODULE.pye
via_pyconcrete.pyd
and execute decrypted data (as .pyc content) - encrypt & decrypt secret key record in
_pyconcrete.pyd
(like DLL or SO) the secret key would be hide in binary code, can't see it directly in HEX view
- only support AES 128 bit now
- encrypt & decrypt by library OpenAES
- need to input your passphrase create secret key for encrypt python script.
- same passphrase will generate the same secret key
- installation will add
pyconcrete.pth
into yoursite-packages
for executesitecustomize.py
under pyconcrete which will automatic import pyconcrete
$ pip install pyconcrete
If you only execute
pip install
will not display any prompt(via stdout) from pyconcrete. Installation will beblocked
andwaiting for user input passphrase twice
. You must input passphrase for installation continuously.
$ pip install pyconcrete --egg --install-option="--passphrase=<your passphrase>"
pyconcrete installed as egg, if you want to uninstall pyconcrete will need to manually delete
pyconcrete.pth
.
- get the pyconcrete source code
$ git clone <pyconcrete repo> <pyconcre dir>
- install pyconcrete
$ python setup.py install
- convert all of your
.py
to*.pye
$ pyconcrete-admin.py compile --source=<your py script> --pye
$ pyconcrete-admin.py compile --source=<your py module dir> --pye
- remove
*.py
*.pyc
or copy*.pye
to other folder - main.py encrypted as main.pye, it can't be executed by normal
python
. You must usepyconcrete
to process the main.pye script.pyconcrete
(exe) will be installed in your system path (ex: /usr/local/bin)
pyconcrete main.pye
src/*.pye # your libs
- download pyconcrete source and install by setup.py
$ python setup.py install \
--install-lib=<your project path> \
--install-scripts=<where you want to execute pyconcrete-admin.py and pyconcrete(exe)>
- import pyconcrete in your main script
- recommendation project layout
main.py # import pyconcrete and your lib
pyconcrete/* # put pyconcrete lib in project root, keep it as original files
src/*.pye # your libs
- test in local
$ ./pyconcrete-admin.py test
- add test case for pyconcrete.exe
- reference exists test case
- add folder in
test/exe_testcases/
- add testing code at
test/exe_testcases/src/main.py
- add validator at
test/exe_testcases/validator.py
pyconcrete is an experimental project, there is always a way to decrypt .pye files, but pyconcrete just make it harder.