Skip to main content

Build Status 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

$ pip install pyconcrete

``pip install`` will not display any prompt(via stdout) from
pyconcrete. Installation will be ``blocked`` and
``waiting for user input passphrase twice``. You must input
passphrase for installation continuously. Hard to control pip to
redirect pyconcrete stdout to console currently.

source

  • get the pyconcrete source code

    $ git clone <pyconcrete repo> <pyconcre dir>
  • install pyconcrete

    $ python setup.py install

Usage

  • convert your script 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 script

  • recommendation project layout

  • python execute main script as *.pye will cause exception, so main script can’t be encrypted

    main.py  # your main scirpt, must can't be encrypted
    src/*.pye  # your libs

Usage (pyconcrete as lib)

  • 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>
  • 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

  • test all case

    $ ./pyconcrete-admin.py test
  • test all case, setup TEST_PYE_PERFORMANCE_COUNT env to reduce testing time

    $ TEST_PYE_PERFORMANCE_COUNT=1 ./pyconcrete-admin.py test

Announcement

pyconcrete is an experimental project, there is always a way to decrypt .pye files, but pyconcrete just make it harder.

Metadata

Release files for pyconcrete 0.10.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyconcrete 0.10.2
File Size Uploaded
pyconcrete-0.10.2.tar.gz 40.4 kB Details

Release files / pyconcrete-0.10.2.tar.gz

Download URL pyconcrete-0.10.2.tar.gz
Size 40.4 kB
Tags Source
SHA-256 checksum
How to use checksums
82cf58e416417139782508609bf3071ba54ac9ebd4305413fe0222ad1b818d6b
BLAKE2b-256 checksum
How to use checksums
77877e91871e0cf39e13c849ab42d29202272670e2b6844035afca5af15587b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.3.0

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.15.2

1 release file

0.15.1

1 release file

0.14.1

1 release file

0.12.1

1 release file

0.11.3

1 release file

0.11.1

1 release file

0.11.0

1 release file

This release

0.10.2 This release

1 release file

0.10.1

1 release file

0.10.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page