Skip to content

Latest commit

 

History

History
119 lines (83 loc) · 4.47 KB

README_en.md

File metadata and controls

119 lines (83 loc) · 4.47 KB

PyEncryption

Chinese Readme

PyEncryption is a command line tool for encrypting python code based on py2sec and py2so

New

  • add command line option -m / --mode, when mode='classical, copy all files in origin directory to target directory, please check document for more use

Change

  • change -m / --maintain to -e / --exclude

Fix

  • compiler error when has .\ in directory path on Windows platform

origin document (updated):

OS Support

Linux && MacOS && Windows

P.S. Windows User May encounter the error

error: command 'cl.exe' failed: No such file or directory

Please install Visual C++ Build Tools matches your Win version

What is py2sec

  1. py2sec is a Cross-Platform, Fast and Flexible tool to change the .py to .so(Linux and Mac) or .pdy(Win).
  2. You can use it to hide the source code of py.
  3. Py2Sec can also speed up the running time of the code, up to 30 times than before.
  4. py2sec can transfer a single file, more of this, it can certainly transfer the whole project at one time!.
  5. The .so(or .pyd) file generated by the .py file can be called by the main func as "from module import * ".
  6. py2sec can detect the .py file and transfer to .so(or .pyd) file, also you can determin which file or directory you don't want to change.
  7. py2sec doesn't affect the origin code, it generate a new file or directory.
  8. py2sec work well with python2 and python3, use -p(--py) to change the python version you want to encrypt.
  9. Provide the multithread option to accelerate the speed of py encryption.

How to config it

pip install requirements.txt

How to use py2sec

Usage

python py2sec.py [options] ...

Options

-v,  --version      Show the version of the py2sec
-h,  --help         Show the help info
-p,  --python       Python version, default is based on the version of python you bind with command "python"
                    Example: -p 3  (means you tends to encrypt python3)
-d,  --directory    Directory of your project (if use -d, you encrypt the whole directory)
-f,  --file         File to be transfered (if use -f, you only encrypt one file)
-m   --mode         only effective when use -d option, value is 'minimal', 'classic' or 'inplace'
                        minimal: compiler .py files store it in result directory
                        classic: compiler .py files and copy other files in result directory
                        inplace: compiler .py files store it in origin directory and delete origin .py file (TODO)
-e,  --exclude      List the file or the directory you don't want to transfer
                    Note: The directories should be suffix by path separate char ('\\' in Windows or '/'),
                    and must be the relative path to -d's value
                    Example: -m setup.py,mod/__init__.py,exclude_dir/
-x,  --nthread      number of parallel thread to build jobs
-q   --quiet        Quiet Mode, Default: False
-r   --release      Release Mode, clear all the tmp files, only output the result, Default: False

Example

python py2sec.py -f test.py
python py2sec.py -f example/test1.py -r
python py2sec.py -d example/ -m test1.py,bbb/

# some OS use command "python3" to run python3, like Ubuntu, you can use -p to solve it
python3 py2sec.py -p 3 -d example/

Project Structure

  • build/ temp files, .o, .so files
  • tmp_build/ temp files, .c files
  • result/ the final result dir, the results store here
  • result/log.txt the log file
  • py2sec.py main run file
  • py2sec_build.py.template to generate setup.py file
  • requirements.txt env to run py2sec

Notification

  1. Please put the project or file you want to encrypt at the same path of py2sec.py
  2. Please use project root path for import statements like from example.aaa import test1 in the script used to start encryption project
  3. Windows Platform should install C++ Build Tools

LICENSE

The Project follow the MIT LICENSE.

Demo

The whole project before:

demo1

After py2sec:

demo2