Skip to main content

A robust tool for Python code obfuscation and encryption using Cython.

Project description

pyshielder - Python Code Shield

Python Version License

pyshielder (formerly pyxblend) is a powerful tool to protect your Python code. It combines advanced multi-layer bytecode obfuscation with native compilation to create highly secure executable scripts.

Features

  • Advanced Layering: Compiles code to bytecode, serializes with Marshal, compresses with Zlib, encodes with Base64, and obfuscates the structure.
  • Strong Encryption: Wraps the obfuscated payload in a secure loader encrypted with rolling-key XOR and SHA-512.
  • Native Compilation: The final loader is compiled into a native C binary using Cython and GCC, executing directly in memory.
  • Tamper Resistant: No original source code or simple bytecode is visible. Reverse engineering requires reconstructing multiple layers of obscured logic.
  • Self-contained: The output is a single Python script that self-compiles and executes.

Installation

pip install pyshielder

Note: You need gcc (or clang) and python3-dev installed on your system to use the encryption tool and to run the generated protected scripts.

Usage

Command Line Interface

You can use pyshielder directly from the command line:

# Encrypt a file
pyshielder my_script.py

# Specify output directory
pyshielder my_script.py --output dist/protected_script.py

Python API

from pyshielder import encrypt

# Encrypt a script string
code = "print('Hello, protected world!')"
loader_code = encrypt(code)

# Save the loader to a file
with open("protected_script.py", "w") as f:
    f.write(loader_code)

How it works

  1. Layer 1 (Bytecode & Encoding): Source code is compiled to bytecode, marshaled, compressed (Zlib), Base64 encoded, and structurally manipulated.
  2. Layer 2 (Encryption): The encoded payload is encrypted using a rolling-key XOR algorithm derived from SHA-512.
  3. Layer 3 (Native Translation): The decryption logic is translated into C code using Cython.
  4. Layer 4 (Loader Generation): A Python loader is generated that compiles the C code into a native extension at runtime and executes it in memory.

License

MIT License - see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyshielder-1.0.3.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyshielder-1.0.3-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pyshielder-1.0.3.tar.gz.

File metadata

  • Download URL: pyshielder-1.0.3.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyshielder-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a269894ba60b1569d076f351208fb784197f016e95df5e580a9c63f63befb901
MD5 85ab46b0157607bec5bd1e0392d03870
BLAKE2b-256 08a1c2d00ae2b1b20a381080e03e8a5d70222c8c4ec9dcb9a10b2b07c8248a89

See more details on using hashes here.

File details

Details for the file pyshielder-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: pyshielder-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyshielder-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c41c93dcf8a2ad02b537c951b0b46becf641b7ef2c0e711e4fce4fff37a0eddf
MD5 eda8351db405a08cf463b586002e3ddb
BLAKE2b-256 a6fd78b6eafaa8b201d0cc9fb8d032113157003b9981e925f3545deda42f997a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page