Code Monkey home page Code Monkey logo

pyconcrete's Introduction

pyconcrete

Protect your python script, encrypt .pyc to .pye and decrypt when import it


Version

0.9.x Beta

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

Usage

  • get the pyconcrete source code
$ git clone <pyconcrete repo> <pyconcre dir>
  • install pyconcrete
$ python setup.py install
  • 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

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

  • install pyconcrete as lib
$ 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 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

pyconcrete's People

Contributors

falldog avatar

Watchers

Ghislain LEVEQUE avatar James Cloos avatar  avatar Thomas Brunet avatar TROUVERIE Joachim avatar Jean Lescut-Muller avatar lahirch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.