Skip to main content

BXShield

BXShield is a practical Python source-hardening toolkit from BXCODE. It combines conservative AST transformations, optional reversible string encoding, CPython bytecode output, SHA-256 integrity manifests, static analysis, and offline Ed25519 license verification.

BXShield raises the effort required for casual inspection and copying. It is not a security boundary and cannot make client-side Python impossible to reverse engineer.

What it protects against

  • Casual source browsing through optional formatting reduction, conservative local-variable renaming, and reversible string encoding.
  • Accidental or untracked modification of build artifacts through a SHA-256 manifest.
  • Basic local license-file forgery when users verify signatures against a trusted public key.

What it does not protect against

  • A determined analyst can inspect bytecode, decode strings, patch the program, or extract runtime data.
  • Bytecode is Python-version-specific and is not impossible to reverse engineer.
  • Base64 string wrapping is encoding/obfuscation, not encryption. It offers no secrecy against an analyst who can inspect the decoder.
  • A client-side license check is not perfect DRM; software under the customer's control can be modified.
  • BXShield does not hide malware, evade security products, or execute source during analysis/build.

Installation

python -m pip install .
# Development installation with tests and tools
python -m pip install '.[dev]'

Python 3.10+ is supported. License signing and verification use the cryptography package.

Quick start

bxshield build examples/hello.py --output dist --profile strong
bxshield verify dist
bxshield analyze examples/hello.py

Python API:

from bxshield import Shield, ShieldConfig

config = ShieldConfig.profile_config("strong", seed=12345, preserve=["main"])
result = Shield(config).protect("examples/hello.py", output="dist")
if not result.success:
    raise RuntimeError(result.errors)
print(result.output, result.files_processed, result.transformations)

Shield.protect accepts either a .py file or a project directory and returns a structured BuildResult. It never imports or executes source files. Directory builds also copy non-Python assets while respecting exclusion globs.

CLI

bxshield --help
bxshield --version
bxshield build project/ --output dist/ --profile strong --seed 12345
bxshield analyze project/ --json
bxshield verify dist/
bxshield config init

Build prints measured phase durations and writes build-report.json. Analysis is static and reports Python version, source files, function/class counts, imports, strings, approximate complexity, and conservative renaming candidates.

Configuration

Create a starter file with bxshield config init:

[project]
name = "MyApp"
version = "1.0.0"

[protection]
profile = "strong"
minify = true
rename = true
strings = true
compile = true
integrity = true
preserve = ["main", "MyPublicClass", "API_VERSION"]
exclude = ["tests/**", "generated_*.py"]
string_exclude = ["PUBLIC_TEXT"]

[rename]
prefix = "_bx_"
seed = 12345

[output]
directory = "dist"

ShieldConfig offers the same controls through Python. Exclusion patterns apply to project-relative paths. string_exclude names preserve assigned literals with those target names. Renaming intentionally limits itself to function-local assigned names in simple scopes; function arguments, module-level names, imports, class APIs, reflective/dynamic scopes and explicit preserved/excluded names remain unchanged to avoid common semantic breaks. A seed makes chosen local names reproducible.

Profiles

  • light: minification, conservative renaming, integrity metadata.
  • strong: light layers plus reversible string encoding and bytecode output.
  • maximum: strong layers with docstring removal; still reversible and version-dependent, not “unbreakable.”

Every layer can be switched independently in ShieldConfig or TOML. The compile layer writes .pyc artifacts using the running interpreter's format; distribute and run with a compatible Python version.

Integrity verification

Builds with integrity enabled include integrity.json containing SHA-256 digests of packaged artifacts. Shield().verify("dist") returns a structured result, identifying changed or missing files. The manifest is not signed and does not authenticate itself; an attacker who can replace both artifacts and manifest can recompute it. Use a trusted signed release channel when authenticity matters.

Offline licensing

Create a developer keypair, keep the private key offline, sign a license, then verify using the distributed public key:

bxshield license keygen --private-key issuer-private.pem --public-key app-public.pem
bxshield license create --product MyApp --license-id BX-1234 \
  --private-key issuer-private.pem --expires-at 2027-01-01 --output license.json
bxshield license verify license.json --public-key app-public.pem --product MyApp

Never embed a private signing key in an application or commit it. Client-side licensing cannot provide perfect DRM. Protect and back up the developer private key independently.

Security and safe operation

  • Parsing and transformation use Python's AST; target files are never executed by analysis or build.
  • There is no anti-debugging, persistence, process injection, hidden network traffic, or AV/EDR evasion.
  • Do not place credentials, permanent secrets, or private signing keys in protected code.
  • See SECURITY.md, docs/security.md, and docs/architecture.md.

Development

python -m compileall bxshield
python -m pytest
ruff check .
python -m build

Tests are local and require no network once development dependencies are installed. examples/hello.py is a smoke-test target. See CONTRIBUTING.md.

Publishing

Build a wheel and source archive with python -m build, inspect the artifacts, and publish only through your trusted release process. Do not include signing private keys, credentials, build caches, or personal data.


Made with ❤️ by BXCODE
https://t.me/bxcode

Metadata

Release files for bxshield 0.1.0

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

Source distribution (sdist)

Source distribution for bxshield 0.1.0
File Size Uploaded Provenance Actions
bxshield-0.1.0.tar.gz 26.8 kB Without provenance Details for bxshield-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bxshield 0.1.0
File Interpreter ABI Platform Actions
bxshield-0.1.0-py3-none-any.whl Python 3 none any Details for bxshield-0.1.0-py3-none-any.whl

Total release size: 52.8 kB

Release files / bxshield-0.1.0.tar.gz

Download URL bxshield-0.1.0.tar.gz
Size 26.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2a798634aa9ac2573a0c7d4ad6d9c56ff50ed05b71cfb4d1d65eda3f5cee135f
BLAKE2b-256 checksum
How to use checksums
94d8a9d7d6f51a158ab14dbd8bf30d4b8fcffbfe32521eb7ec2da5748aebe68f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / bxshield-0.1.0-py3-none-any.whl

Download URL bxshield-0.1.0-py3-none-any.whl
Size 26.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a608cac0504c579dec2e34d10ff83fe7d9fbda302f4dcff394235cd58f51a0a
BLAKE2b-256 checksum
How to use checksums
82bd11c38ac8c15a5669c8b44650a13873276a6d1239f5247392cbc6d7f7b4ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Security for bxshield 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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