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.
Metadata
Release files for sourceprotected 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sourceprotected-0.1.0.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sourceprotected-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.1 kB
Release files / sourceprotected-0.1.0.tar.gz
| Download URL | sourceprotected-0.1.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4cf6e6277e06c9990abdf6cb0572757cbb3f8ac3b75f77b9d8d1fa99f1830bb
|
|
BLAKE2b-256 checksum How to use checksums |
ab5b5d8aa6559f085201141aa04ae59a4fbc045d500cea3a5d8aede508f26a79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / sourceprotected-0.1.0-py3-none-any.whl
| Download URL | sourceprotected-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
767867a731012903f18ac2fad3f5e2c64c90a4fe94a42b7bbb1cfe1f58968678
|
|
BLAKE2b-256 checksum How to use checksums |
1b6b707ee600a5d3fcaf5a2cbb3aac7ea035d76ccce52a35516eb307432e6ed5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|