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.2.tar.gz (9.8 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.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyshielder-1.0.2.tar.gz
  • Upload date:
  • Size: 9.8 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.2.tar.gz
Algorithm Hash digest
SHA256 363f076b9d4f879215adafd5913e0147e1b2e94276359d77e11afb88d3b79bf3
MD5 098412b400d3b40c6dc6aec7ad782193
BLAKE2b-256 8ad79f71cbd2504889c836cd4284a3ef63ae78e0281d2d223eb3987fc61d9404

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyshielder-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 93da3a546f90cb2e15eef29067f4a8691390c489e6afae87b2613f10650caff4
MD5 d980f5ef9d79a1f0fabfa0f5925edfbe
BLAKE2b-256 9a60cfc487d9a7d96fef181980aaa2cfd2b112e1441e9077871fc3f28091aec8

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