Encrypt Python source files and decrypt them on the fly during runtime
Project description
sourceprotected
Encrypt Python source files and decrypt them on the fly during runtime.
Usage
Installation
Using pip
:
pip install sourceprotected
Encrypting the source files
sourceprotected path/to/src(.py)
Using key: fHC79...
Using encryption time: 1694...
Decrypt during runtime
With sourceprotected
installed in your current environment, you can run/import encrypted files/modules as long as the SOURCEPROTECTED_KEY
environment variable is set:
encrypted.py
:
# -*- coding: sourceprotected -*-
-----BEGIN SOURCEPROTECTED FILE-----
gAAAAABk-eJaJarzMWy70GTRkRi6kjaD-zJy
-fHX_0G5VHTZjEKxJUvFhVWfWpX_j3LydmJo
pn7YrAj5CSqqPWgxUY_dSk5ELA==
-----END SOURCEPROTECTED FILE-----
main.py
:
import encrypted # Will decrypt encrypted.py on the fly.
Finally:
SOURCEPROTECTED_KEY=Bk92p... python -B main.py
How does it work?
sourceprotected
uses a custom codec that will decrypt the file content using the SOURCEPROTECTED_KEY
environment variable.
This codec is registered on startup by using a .pth
file.
Credits goes to https://github.com/asottile-archive/future-fstrings for the implementation idea.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sourceprotected-0.1.0.tar.gz
.
File metadata
- Download URL: sourceprotected-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4cf6e6277e06c9990abdf6cb0572757cbb3f8ac3b75f77b9d8d1fa99f1830bb |
|
MD5 | d43b8965079bc1e16a19d0bff454167a |
|
BLAKE2b-256 | ab5b5d8aa6559f085201141aa04ae59a4fbc045d500cea3a5d8aede508f26a79 |
File details
Details for the file sourceprotected-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: sourceprotected-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 767867a731012903f18ac2fad3f5e2c64c90a4fe94a42b7bbb1cfe1f58968678 |
|
MD5 | e12a755a6c94259b3b68c52d4e63229e |
|
BLAKE2b-256 | 1b6b707ee600a5d3fcaf5a2cbb3aac7ea035d76ccce52a35516eb307432e6ed5 |