pyconcrete
==========
|Travis| |AppVeyor| |PyPI Version| |PyPI PyVersion| |PyPI License|
Protect your python script, encrypt .pyc to .pye and decrypt when import
it
--------------
Protect python script work flow
-------------------------------
- your_script.py ``import pyconcrete``
- pyconcrete will hook import module
- when your script do ``import MODULE``, pyconcrete import hook will try
to find ``MODULE.pye`` first and then decrypt ``MODULE.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
Encryption
----------
- only support AES 128 bit now
- encrypt & decrypt by library OpenAES
Installation
------------
- 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 your ``site-packages``
for execute ``sitecustomize.py`` under pyconcrete which will automatic
import pyconcrete
pip
~~~
You must set up environment variable ``PYCONCRETE_PASSPHRASE`` for
installation continuously.
.. code:: sh
$ PYCONCRETE_PASSPHRASE=<your passphrase here> pip install pyconcrete
or, if you use an old pip version that supports –egg:
.. code:: sh
$ 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``.
source
~~~~~~
- get the pyconcrete source code
.. code:: sh
$ git clone <pyconcrete repo> <pyconcre dir>
- install pyconcrete
.. code:: sh
$ python setup.py install
Usage
-----
Full encrypted
~~~~~~~~~~~~~~
- convert all of your ``.py`` to ``*.pye``
.. code:: sh
$ 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 use ``pyconcrete`` to process the *main*.pye
script. ``pyconcrete``\ (*exe*) will be installed in your system path
(ex: /usr/local/bin)
.. code:: sh
pyconcrete main.pye
src/*.pye # your libs
Partial encrypted (pyconcrete as lib)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- download pyconcrete source and install by setup.py
.. code:: sh
$ 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
.. code:: sh
main.py # import pyconcrete and your lib
pyconcrete/* # put pyconcrete lib in project root, keep it as original files
src/*.pye # your libs
Test
----
- test in local
.. code:: sh
$ ./pyconcrete-admin.py test
- test in docker environment
.. code:: sh
$ ./bin/run-test.sh
- 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``
Example
-------
`Django with pyconcrete <example/django>`__
Building on Linux
-----------------
Python 3.7 - fix Ubuntu 14.04 build error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: bash
x86_64-linux-gnu-gcc: error: unrecognized command line option `-fstack-protector-strong`
Reference by `Stackoverflow
solution <https://stackoverflow.com/questions/27182042/pip-error-unrecognized-command-line-option-fstack-protector-strong>`__
\* you should install ``gcc-4.9`` first \* symlink
``/usr/bin/x86_64-linux-gnu-gcc`` to ``gcc-4.9`` \* build pycocnrete
again \* rollback symlink
Building on Windows
-------------------
Python 2.7 - Visual Studio 2008
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
https://www.microsoft.com/en-us/download/details.aspx?id=44266
- Open VS2008 Command Prompt
- ``set DISTUTILS_USE_SDK=1``
- ``set SET MSSdk=1``
- create ``distutils.cfg`` and put inside
``text [build] compiler=msvc``
Python 3.5, 3.6, 3.7 - Visual Studio 2015
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`MSVC 2015 Build
Tools <http://landinghub.visualstudio.com/visual-cpp-build-tools>`__
`Document <https://matthew-brett.github.io/pydagogue/python_msvc.html#python-3-5-3-6>`__
- make sure setuptools >= 24.0
``sh python -c 'import setuptools; print(setuptools.__version__)'``
- Open VS2015 Build Tools Command Prompt
- ``set DISTUTILS_USE_SDK=1``
- ``setenv /x64 /release`` or ``setenv /x86 /release``
Reference
~~~~~~~~~
https://matthew-brett.github.io/pydagogue/python_msvc.html
https://github.com/cython/cython/wiki/CythonExtensionsOnWindows
Announcement
------------
pyconcrete is an experimental project, there is always a way to decrypt
.pye files, but pyconcrete just make it harder.
.. |Travis| image:: https://img.shields.io/travis/Falldog/pyconcrete.svg?label=travis
:target: https://travis-ci.org/Falldog/pyconcrete
.. |AppVeyor| image:: https://img.shields.io/appveyor/ci/Falldog/pyconcrete.svg?label=appveyor
:target: https://ci.appveyor.com/project/Falldog/pyconcrete
.. |PyPI Version| image:: https://img.shields.io/pypi/v/pyconcrete.svg
:target: https://pypi.python.org/pypi/pyconcrete
.. |PyPI PyVersion| image:: https://img.shields.io/pypi/pyversions/pyconcrete.svg
:target: https://pypi.python.org/pypi/pyconcrete
.. |PyPI License| image:: https://img.shields.io/pypi/l/pyconcrete.svg
:target: https://pypi.python.org/pypi/pyconcrete
Raw data
{
"_id": null,
"home_page": "https://github.com/Falldog/pyconcrete",
"name": "pyconcrete",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python source encryption obfuscation",
"author": "Falldog",
"author_email": "falldog7@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/66/5d/bb236da2f85bf9ca0200a19dd45e9588c65a3b3e0eed325a6290b63847ad/pyconcrete-0.15.2.tar.gz",
"platform": null,
"description": "pyconcrete\n==========\n\n|Travis| |AppVeyor| |PyPI Version| |PyPI PyVersion| |PyPI License|\n\nProtect your python script, encrypt .pyc to .pye and decrypt when import\nit\n\n--------------\n\nProtect python script work flow\n-------------------------------\n\n- your_script.py ``import pyconcrete``\n- pyconcrete will hook import module\n- when your script do ``import MODULE``, pyconcrete import hook will try\n to find ``MODULE.pye`` first and then decrypt ``MODULE.pye`` via\n ``_pyconcrete.pyd`` and execute decrypted data (as .pyc content)\n- encrypt & decrypt secret key record in ``_pyconcrete.pyd`` (like DLL\n or SO) the secret key would be hide in binary code, can\u2019t see it\n directly in HEX view\n\nEncryption\n----------\n\n- only support AES 128 bit now\n- encrypt & decrypt by library OpenAES\n\nInstallation\n------------\n\n- need to input your passphrase create secret key for encrypt python\n script.\n- same passphrase will generate the same secret key\n- installation will add ``pyconcrete.pth`` into your ``site-packages``\n for execute ``sitecustomize.py`` under pyconcrete which will automatic\n import pyconcrete\n\npip\n~~~\n\nYou must set up environment variable ``PYCONCRETE_PASSPHRASE`` for\ninstallation continuously.\n\n.. code:: sh\n\n $ PYCONCRETE_PASSPHRASE=<your passphrase here> pip install pyconcrete\n\nor, if you use an old pip version that supports \u2013egg:\n\n.. code:: sh\n\n $ pip install pyconcrete --egg --install-option=\"--passphrase=<your passphrase>\"\n\n..\n\n pyconcrete installed as egg, if you want to uninstall pyconcrete will\n need to manually delete ``pyconcrete.pth``.\n\nsource\n~~~~~~\n\n- get the pyconcrete source code\n\n.. code:: sh\n\n $ git clone <pyconcrete repo> <pyconcre dir>\n\n- install pyconcrete\n\n.. code:: sh\n\n $ python setup.py install\n\nUsage\n-----\n\nFull encrypted\n~~~~~~~~~~~~~~\n\n- convert all of your ``.py`` to ``*.pye``\n\n.. code:: sh\n\n $ pyconcrete-admin.py compile --source=<your py script> --pye\n $ pyconcrete-admin.py compile --source=<your py module dir> --pye\n\n- remove ``*.py`` ``*.pyc`` or copy ``*.pye`` to other folder\n- *main*.py encrypted as *main*.pye, it can\u2019t be executed by normal\n ``python``. You must use ``pyconcrete`` to process the *main*.pye\n script. ``pyconcrete``\\ (*exe*) will be installed in your system path\n (ex: /usr/local/bin)\n\n.. code:: sh\n\n pyconcrete main.pye\n src/*.pye # your libs\n\nPartial encrypted (pyconcrete as lib)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n- download pyconcrete source and install by setup.py\n\n.. code:: sh\n\n $ python setup.py install \\\n --install-lib=<your project path> \\\n --install-scripts=<where you want to execute pyconcrete-admin.py and pyconcrete(exe)>\n\n- import pyconcrete in your main script\n\n - recommendation project layout\n\n .. code:: sh\n\n main.py # import pyconcrete and your lib\n pyconcrete/* # put pyconcrete lib in project root, keep it as original files\n src/*.pye # your libs\n\nTest\n----\n\n- test in local\n\n.. code:: sh\n\n $ ./pyconcrete-admin.py test\n\n- test in docker environment\n\n.. code:: sh\n\n $ ./bin/run-test.sh\n\n- add test case for pyconcrete.exe\n\n - reference exists test case\n - add folder in ``test/exe_testcases/``\n - add testing code at ``test/exe_testcases/src/main.py``\n - add validator at ``test/exe_testcases/validator.py``\n\nExample\n-------\n\n`Django with pyconcrete <example/django>`__\n\nBuilding on Linux\n-----------------\n\nPython 3.7 - fix Ubuntu 14.04 build error\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: bash\n\n x86_64-linux-gnu-gcc: error: unrecognized command line option `-fstack-protector-strong`\n\nReference by `Stackoverflow\nsolution <https://stackoverflow.com/questions/27182042/pip-error-unrecognized-command-line-option-fstack-protector-strong>`__\n\\* you should install ``gcc-4.9`` first \\* symlink\n``/usr/bin/x86_64-linux-gnu-gcc`` to ``gcc-4.9`` \\* build pycocnrete\nagain \\* rollback symlink\n\nBuilding on Windows\n-------------------\n\nPython 2.7 - Visual Studio 2008\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nhttps://www.microsoft.com/en-us/download/details.aspx?id=44266\n\n- Open VS2008 Command Prompt\n- ``set DISTUTILS_USE_SDK=1``\n- ``set SET MSSdk=1``\n- create ``distutils.cfg`` and put inside\n ``text [build] compiler=msvc``\n\nPython 3.5, 3.6, 3.7 - Visual Studio 2015\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n`MSVC 2015 Build\nTools <http://landinghub.visualstudio.com/visual-cpp-build-tools>`__\n\n`Document <https://matthew-brett.github.io/pydagogue/python_msvc.html#python-3-5-3-6>`__\n\n- make sure setuptools >= 24.0\n ``sh python -c 'import setuptools; print(setuptools.__version__)'``\n\n- Open VS2015 Build Tools Command Prompt\n\n- ``set DISTUTILS_USE_SDK=1``\n\n- ``setenv /x64 /release`` or ``setenv /x86 /release``\n\nReference\n~~~~~~~~~\n\nhttps://matthew-brett.github.io/pydagogue/python_msvc.html\nhttps://github.com/cython/cython/wiki/CythonExtensionsOnWindows\n\nAnnouncement\n------------\n\npyconcrete is an experimental project, there is always a way to decrypt\n.pye files, but pyconcrete just make it harder.\n\n.. |Travis| image:: https://img.shields.io/travis/Falldog/pyconcrete.svg?label=travis\n :target: https://travis-ci.org/Falldog/pyconcrete\n.. |AppVeyor| image:: https://img.shields.io/appveyor/ci/Falldog/pyconcrete.svg?label=appveyor\n :target: https://ci.appveyor.com/project/Falldog/pyconcrete\n.. |PyPI Version| image:: https://img.shields.io/pypi/v/pyconcrete.svg\n :target: https://pypi.python.org/pypi/pyconcrete\n.. |PyPI PyVersion| image:: https://img.shields.io/pypi/pyversions/pyconcrete.svg\n :target: https://pypi.python.org/pypi/pyconcrete\n.. |PyPI License| image:: https://img.shields.io/pypi/l/pyconcrete.svg\n :target: https://pypi.python.org/pypi/pyconcrete\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Protect your python script, encrypt it as .pye and decrypt when import it",
"version": "0.15.2",
"project_urls": {
"Homepage": "https://github.com/Falldog/pyconcrete"
},
"split_keywords": [
"python",
"source",
"encryption",
"obfuscation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "665dbb236da2f85bf9ca0200a19dd45e9588c65a3b3e0eed325a6290b63847ad",
"md5": "20673971efdce0e454acae9fa7ccabd4",
"sha256": "a61c62c59125401ca8e9652afcc7534617f2aa6434dccecfbe5adf979b6ef37a"
},
"downloads": -1,
"filename": "pyconcrete-0.15.2.tar.gz",
"has_sig": false,
"md5_digest": "20673971efdce0e454acae9fa7ccabd4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 52715,
"upload_time": "2025-02-17T01:19:08",
"upload_time_iso_8601": "2025-02-17T01:19:08.327257Z",
"url": "https://files.pythonhosted.org/packages/66/5d/bb236da2f85bf9ca0200a19dd45e9588c65a3b3e0eed325a6290b63847ad/pyconcrete-0.15.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-17 01:19:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Falldog",
"github_project": "pyconcrete",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"appveyor": true,
"lcname": "pyconcrete"
}