Package: pyconcrete
Protect your python script, encrypt .pyc to .pye and decrypt when import
itProtect python script work flowyour_script.pyimport pyconcretepyconcrete will hook import modulewhen your script doimport MODULE, pyconcrete import hook will
try to findMODULE.pyefirst and then decryptMODULE.pyevia_pyconcrete.pydand 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 viewEncryptiononly support AES 128 bit nowencrypt & decrypt by library OpenAESInstallationneed to input your passphrase create secret key for encrypt python
script.same passphrase will generate the same secret keyinstallation will addpyconcrete.pthinto yoursite-packagesfor executesitecustomize.pyunder pyconcrete which will
automatic import pyconcretepipYou must set up environment variablePYCONCRETE_PASSPHRASEfor
installation continuously.$PYCONCRETE_PASSPHRASE=<yourpassphrasehere>pipinstallpyconcreteor, if you use an old pip version that supports –egg:$pipinstallpyconcrete--egg--install-option="--passphrase=<your passphrase>"pyconcrete installed as egg, if you want to uninstall pyconcrete will
need to manually deletepyconcrete.pth.sourceget the pyconcrete source code$gitclone<pyconcreterepo><pyconcredir>install pyconcrete$pythonsetup.pyinstallUsageFull encryptedconvert all of your.pyto*.pye$pyconcrete-admin.pycompile--source=<yourpyscript>--pye$pyconcrete-admin.pycompile--source=<yourpymoduledir>--pyeremove*.py*.pycor copy*.pyeto other foldermain.py encrypted asmain.pye, it can’t be executed by normalpython. You must usepyconcreteto process themain.pye
script.pyconcrete(exe) will be installed in your system path
(ex: /usr/local/bin)pyconcretemain.pyesrc/*.pye# your libsPartial encrypted (pyconcrete as lib)download pyconcrete source and install by setup.py$pythonsetup.pyinstall\--install-lib=<yourprojectpath>\--install-scripts=<whereyouwanttoexecutepyconcrete-admin.pyandpyconcrete(exe)>import pyconcrete in your main scriptrecommendation project layoutmain.py# import pyconcrete and your libpyconcrete/*# put pyconcrete lib in project root, keep it as original filessrc/*.pye# your libsTesttest in local$./pyconcrete-admin.pytesttest in docker environment$./bin/run-test.shadd test case for pyconcrete.exereference exists test caseadd folder intest/exe_testcases/add testing code attest/exe_testcases/src/main.pyadd validator attest/exe_testcases/validator.pyExampleDjango with pyconcreteBuilding on LinuxPython 3.7 - fix Ubuntu 14.04 build errorx86_64-linux-gnu-gcc:error:unrecognizedcommandlineoption`-fstack-protector-strong`Reference byStackoverflow
solution* you should installgcc-4.9first * symlink/usr/bin/x86_64-linux-gnu-gcctogcc-4.9* build pycocnrete
again * rollback symlinkBuilding on WindowsPython 2.7 - Visual Studio 2008https://www.microsoft.com/en-us/download/details.aspx?id=44266Open VS2008 Command Promptset DISTUTILS_USE_SDK=1set SET MSSdk=1createdistutils.cfgand put insidetext   [build]   compiler=msvcPython 3.5, 3.6, 3.7 - Visual Studio 2015MSVC 2015 Build
ToolsDocumentmake sure setuptools >= 24.0sh   python-c'import setuptools; print(setuptools.__version__)'Open VS2015 Build Tools Command Promptset DISTUTILS_USE_SDK=1setenv /x64 /releaseorsetenv /x86 /releaseReferencehttps://matthew-brett.github.io/pydagogue/python_msvc.htmlhttps://github.com/cython/cython/wiki/CythonExtensionsOnWindowsAnnouncementpyconcrete is an experimental project, there is always a way to decrypt
.pye files, but pyconcrete just make it harder.