GitXplorerGitXplorer
V

sourceprotected

public
2 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
a9525d103603960456b2bfa5617a6f8f6264ae74

Add project links

VViicos committed a year ago
Unverified
c19aee7b5fb1876ed58877caf290d98fb9cf7ddf

Add `CHANGELOG.md` and clarify `README.md`

VViicos committed a year ago
Unverified
edb94a25fd712df2b4f7a0498dfa43e23d4f3ac3

Several fixes

VViicos committed a year ago
Verified
08b3d6c1bdc2b511d2e4b949e6edc2fdac3256d8

Create LICENSE

VViicos committed a year ago
Unverified
fba59065dc37d82bbf96a327d0e5ce63ecd9bb15

Initial commit

VViicos committed a year ago

README

The README file for this repository.

sourceprotected

Encrypt Python source files and decrypt them on the fly during runtime.

Python versions Code style: Black Ruff

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.