- Example of encrypting a python script using the pyconcrete
- I recommend that you should ignore the commented instructions with an octothorpe, #.
- Modified date: July 26, 2020.
- Summarized environments about the Pyconcrete-Python
- Create a virtualenv for python3 and activate it.
- Install python packages.
- Run a demo code without encyrption
- Encrypt a python source code using the pyconcrete and run a demo code with encryption.
- Encrypt all python source codes using the pyconcrete and run a demo code with encryption.
- Operating System (OS): Ubuntu MATE 18.04.3 LTS (Bionic)
- Graphics Processing Unit (GPU): NVIDIA TITAN Xp, 1ea
- GPU driver: Nvidia-440.100
- CUDA toolkit: CUDA 10.2
- cuDNN: cuDNN v7.6.5
- The root directory for the virtualenv: /home/usrname/pip3_virtualenv
- The name of new virtualenv to be created: pyconcrete
- Please note that the python version (e.g. python3.6) to be installed should be equal to the default python3 version for a python3 package, pyconcrete.
usrname@hostname:~/curr_path$ mkdir -p /home/usrname/pip3_virtualenv/pyconcrete
usrname@hostname:~/curr_path$ virtualenv /home/usrname/pip3_virtualenv/pyconcrete/ --python=python3.6
usrname@hostname:~/curr_path$ source /home/usrname/pip3_virtualenv/pyconcrete/bin/activate
(pyconcrete) usrname@hostname:~/curr_path$
- The name of activated virtualenv: pyconcrete
- I recommend that you should install the python package, pyconcrete from source, not pip3.
- Thus, the provided requirements.txt does not include the python3 package, pyconcrete.
(pyconcrete) usrname@hostname:~/curr_path$ git clone https://github.com/vujadeyoon/Pyconcrete-Python
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$ pip3 install -r requirements.txt
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$ mkdir -p /home/usrname/pip3_packages
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$ git clone https://github.com/Falldog/pyconcrete /home/usrname/pip3_packages/pyconcrete
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$ cd /home/usrname/pip3_packages/pyconcrete
(pyconcrete) usrname@hostname:~/pyconcrete$ python setup.py install
(pyconcrete) usrname@hostname:~/pyconcrete$ cd ~/Pyconcrete-Python
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$
- Please note that you should download a checkpoint for the pretrained model, resnet18 (i.e. resnet18-5c106cde.pth) from the Facebook torchvision using the wget.
- Please note that you should prepare an image to ./Pyconcrete-Python/image.png.
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$ wget "https://download.pytorch.org/models/resnet18-5c106cde.pth"
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$ python3 main.py
torch.Size([1000])
tensor(800, device='cuda:0')
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$
- If you have not prepared the checkpoint and image, please refer to the section 4 and prepare them.
- The path for a python source code to be encrypted: ~/Pyconcrete-Python/resnet.py
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$ cd /home/usrname/pip3_packages/pyconcrete
(pyconcrete) usrname@hostname:~/pyconcrete$ pyconcrete-admin.py compile --source=~/Pyconcrete-Python/resnet.py --pye
(pyconcrete) usrname@hostname:~/pyconcrete$ rm -rf ~/Pyconcrete-Python/resnet.py
(pyconcrete) usrname@hostname:~/pyconcrete$ cd ~/Pyconcrete-Python
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$ python3 main.py
torch.Size([1000])
tensor(800, device='cuda:0')
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$
- If you have not prepared the checkpoint and image, please refer to the section 4 and prepare them.
- The path for a python source code to be encrypted: ~/Pyconcrete-Python/*.py
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$ cd /home/usrname/pip3_packages/pyconcrete
(pyconcrete) usrname@hostname:~/pyconcrete$ pyconcrete-admin.py compile --source=~/Pyconcrete-Python/ --pye
(pyconcrete) usrname@hostname:~/pyconcrete$ find ~/Pyconcrete-Python/ -name "*.py" -exec rm -rf {} \;
(pyconcrete) usrname@hostname:~/pyconcrete$ cd ~/Pyconcrete-Python
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$ pyconcrete main.pye
torch.Size([1000])
tensor(800, device='cuda:0')
(pyconcrete) usrname@hostname:~/Pyconcrete-Python$