Skip to main content

pyencrypt-pye 


Python package Python version PyPI package  PyPI download GitHub  GitHub last commit (by committer) 

encrypt python source code and import module dynamically.

                                                      _
         _ __  _   _  ___ _ __   ___ _ __ _   _ _ __ | |_
        | '_ \| | | |/ _ \ '_ \ / __| '__| | | | '_ \| __|
        | |_) | |_| |  __/ | | | (__| |  | |_| | |_) | |_
        | .__/ \__, |\___|_| |_|\___|_|   \__, | .__/ \__|
        |_|    |___/                      |___/|_|

        encrypt python source code and import dynamically.

                    VERSION 0.5.1

How to do

https://github.com/ZhaoQi99/pyencrypt-pye/wiki#how-to-do

Install

pip install pyencrypt-pye
✨🍰✨

Or you can use pip install git+https://github.com/ZhaoQi99/pyencrypt-pye.git install latest version.

Examples

View examples in the examples directory.

Usage

Usage: pyencrypt [OPTIONS] COMMAND [ARGS]...

Options:
  --version   Show the version and exit.
  -h, --help  Show this message and exit.

Commands:
  decrypt   Decrypt encrypted pye file
  encrypt   Encrypt your python code
  generate  Generate loader file using specified key
  license   Generate license file using specified key

Encrypt

~$ pyencrypt encrypt -h
Usage: pyencrypt encrypt [OPTIONS] PATHNAME

  Encrypt your python code

Options:
  -i, --in-place                  make changes to files in place
  -k, --key 🔑                     Your encryption key.If you don‘t specify
                                  key, pyencrypt will generate encryption key
                                  randomly.  [env var: PYE_ENCRYPT_KEY]
  --without-loader                Don't generate loader file
  --with-license                  Add license to encrypted file
  -m, --bind-mac 01:23:45:67:89:AB
                                  Bind mac address to encrypted file
  -4, --bind-ipv4 192.168.0.1     Bind ipv4 address to encrypted file
  -b, --before [%Y-%m-%dT%H:%M:%S %z|%Y-%m-%d %H:%M:%S|%Y-%m-%d]
                                  License is invalid before this date.
  -a, --after [%Y-%m-%dT%H:%M:%S %z|%Y-%m-%d %H:%M:%S|%Y-%m-%d]
                                  License is invalid after this date.
  -y, --yes                       Automatically answer yes for confirm
                                  questions.
  -h, --help                      Show this message and exit.

Entry File

In your entry file, you must import loader firstly, and then you can import encrypted modules as usual.

import loader
from test import *

Decrypt

~$ pyencrypt decrypt -h
Usage: pyencrypt decrypt [OPTIONS] PATHNAME

  Decrypt encrypted pye file

Options:
  -i, --in-place  make changes to files in place
  -k, --key 🔑     Your encryption key.  [required]
  -h, --help      Show this message and exit.

Generate

~$ pyencrypt generate -h
Usage: pyencrypt generate [OPTIONS]

  Generate loader file using specified key

Options:
  -k, --key 🔑  Your encryption key.  [required]
  -h, --help   Show this message and exit.

License

pyencrypt's loader will search for the license file in the following manner:

  1. ~/.licenses/license.lic file in your home directory.

  2. licenses/license.lic file in loader file's directory.

  3. licenses/license.lic file in the current working directory.

~$ pyencrypt license -h
   Usage: pyencrypt license [OPTIONS]

   Generate license file  using specified key

Options:
  -h, --help                      Show this message and exit.
  -k, --key 🔑     Your encryption key.  [required]
  -m, --bind-mac 01:23:45:67:89:AB
                                  Bind mac address to encrypted file
  -4, --bind-ipv4 192.168.0.1     Bind ipv4 address to encrypted file
  -b, --before [%Y-%m-%dT%H:%M:%S %z|%Y-%m-%d %H:%M:%S|%Y-%m-%d]
                                  License is invalid before this date.
  -a, --after [%Y-%m-%dT%H:%M:%S %z|%Y-%m-%d %H:%M:%S|%Y-%m-%d]
                                  License is invalid after this date.

Shell Completion

Bash Add this to ~/.bashrc:
eval "$(_PYENCRYPT_COMPLETE=bash_source pyencrypt)"
Zsh Add this to ~/.zshrc:
eval "$(_PYENCRYPT_COMPLETE=zsh_source pyencrypt)"
Fish Add this to ~/.config/fish/completions/foo-bar.fish:
eval (env _PYENCRYPT_COMPLETE=fish_source pyencrypt)

Example

Encrypt

~$ pyencrypt encrypt --in-place  -y test.py
~$ pyencrypt encrypt test/
~$ pyencrypt encrypt test.py -y --with-license\
    --before="2000-01-01T00:00:00 +0800" --after="2030-01-01T00:00:00 +0800"\
    --bind-mac="AC:DE:48:00:11:22" --bind-ipv4="192.168.0.1"

Decrypt

~$ pyencrypt decrypt -k xxx test.pye

Generate

~$ pyencrypt generate -k xxx

License

~$ pyencrypt license -k xxx\
    --before="2000-01-01T00:00:00 +0800" --after="2030-01-01T00:00:00 +0800"\
    --bind-mac="AC:DE:48:00:11:22" --bind-ipv4="192.168.0.1"

FAQ

See FAQ for frequently asked questions.

Development

Format Code

black pyencrypt 
isort pyencrypt

License

GNU General Public License v3.0

Author

Metadata

Release files for pyencrypt-pye 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyencrypt-pye 0.5.1
File Size Uploaded Provenance
pyencrypt_pye-0.5.1.tar.gz 46.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyencrypt-pye 0.5.1
File Interpreter ABI Platform
pyencrypt_pye-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 88.9 kB

Release files / pyencrypt_pye-0.5.1.tar.gz

Download URL pyencrypt_pye-0.5.1.tar.gz
Size 46.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f1a157fc6231ee3028fcb213c5ffaef5299ee81acf6dd395ca282cf851d18306
BLAKE2b-256 checksum
How to use checksums
04c57be770e67c1fa496b21ec56875bfd56df30507215fac8a4f9c54dfdd945a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / pyencrypt_pye-0.5.1-py3-none-any.whl

Download URL pyencrypt_pye-0.5.1-py3-none-any.whl
Size 42.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5533b68b649babcfc008acc16ce76966ebe7e99994aa2175f06db1d16360a34
BLAKE2b-256 checksum
How to use checksums
40ba7c6df4dfd9589068ba63213a2e0d95350ac8acf6f8e2cb48ba1d07350f6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for pyencrypt-pye 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page