Skip to main content

BEXAR

BEXAR is an independent Python source protection and compilation toolkit. It is designed to make casual source inspection harder through documented, semantics-conscious transformations; it does not promise perfect secrecy. Obfuscation, compilation, packaging, and encryption are different techniques.

Status

Version 0.1.0 provides an initial source-protection engine, static Python source inspection, non-executing source verification, bounded static project-import analysis, SHA-256 file integrity manifests, and a reproducible .pyz packaging workflow.

bexar -p FILE.py applies the strongest implemented protection profile and writes one protected .py file (default FILE_bexar.py). Today that means:

  • scope-aware identifier renaming — locals, closure cells, comprehension targets and unambiguous import aliases are renamed to opaque generated names (built only from I and l, so they read as noise), while parameters, module-level names and class attributes are left intact;
  • string and bytes literal protection — eligible literals are replaced by calls to a generated decoder that rebuilds them from a masked payload, so URLs, SQL, tokens and messages no longer appear as plain text. When the four section names are free the payload pool is carried by the BEXAR-PROTECTED data header (magic, love, god, destiny plus descriptive metadata) and each literal becomes a lookup into that pool;
  • numeric constant protection — eligible integer and float literals are replaced by equivalent arithmetic that the interpreter folds back to the same value, so ports, timeouts and protocol constants are no longer readable as literals.

The generated part of a protected file contains no readable keywords, no imports and no builtin names. The decoder is a single lambda assignment, every name it needs (__import__, base64, b85decode, zlib, decompress, len, ValueError, enumerate, join, zip_longest, itertools, ...) is carried as a masked %c literal rather than as an identifier, builtins are reached through a frame object instead of the builtins module, and the generated lambda takes unused junk parameters so its signature does not match the decoder it actually implements. Every protected module is stamped with the " Bexar made by Bashar " watermark inside a generated tuple statement, which also carries deterministic filler strings that lengthen the output in proportion to the encoded payload. The banner comments at the top of a protected file are four lines — format name and version, section names, pool checksum, watermark — and no longer describe the pool layout, the distribution rule or the decoder signature. Only the statements of the original program — including its own def, class and return — are reproduced verbatim, because the verifier requires the protected output to re-parse to the same statement and node shape as the input.

Control-flow transformation, runtime integrity and native compilation are declared stages that are not implemented; every protection report lists them explicitly rather than implying coverage. bexar doctor prints the same stage list, the selected interpreter and any detected optional backend.

Protection is not a security guarantee. Renaming, literal masking and constant rewriting make casual source reading harder; they do not make code unrecoverable — the generated decoder ships in the output, so anyone who reads it can recover every payload, and every constant is recoverable by evaluating its expression. The engine refuses to transform any file whose behavior it cannot reason about statically. See docs/commands.md for the transformation scope, refusal rules and measured performance, and the roadmap for the gap analysis and engineering plan.

Install for development

python -m pip install -e .
bexar --version
bexar help
bexar -p main.py
bexar inspect main.py
bexar package main.py --output dist
python .\dist\main.pyz

Requires Python 3.11 or newer. BEXAR currently has no runtime dependencies.

Safety

BEXAR's static-analysis and protection commands do not execute input programs. Behavioral comparison of original and protected code happens only in the test suite, against fixtures BEXAR itself controls, in separate subprocesses.

bexar -p FILE.py parses the input, rewrites the AST, re-parses and compiles the generated module, checks that the output has the same AST node-type histogram and binds the same module-level names, and only then writes the result atomically. If any check fails, nothing is written and the run exits non-zero. The input file is never overwritten unless --in-place is given explicitly.

bexar inspect reads source with Python's encoding-cookie detection, rejects files above 64 MiB by default, and reports syntax errors without executing the file. The limit can be adjusted with --max-bytes.

bexar verify FILE additionally checks Python compile-time constraints by building and discarding a code object. It never evaluates that object or runs the inspected file. This is a source-validity check, not a protection or generated-output integrity guarantee.

bexar analyze DIRECTORY scans Python source statically. It reports project, standard-library, external-or-unresolved, and dynamic import references. It does not install dependencies, import project modules, or prove that a project can be bundled into a single file.

bexar integrity create FILE creates a deterministic .bexar.json sidecar; bexar integrity verify FILE checks the file against it. A hash manifest is not signed, so it only detects tampering when the manifest itself comes from a trusted source.

bexar package ENTRY.py --output DIRECTORY creates one .pyz ZIP application containing the entry point and statically reachable local Python modules. Detected external or unresolved imports and dynamic imports are reported. Native extensions and non-Python resources are not bundled or scanned, and the report therefore does not claim the result is self-contained. Optional --signature SIGNATURE --public-key KEY checks an OpenSSL SHA-256 detached signature over the completed .pyz archive before publishing it. The public key must be trusted independently; BEXAR does not generate keys or signatures. See docs/commands.md for limits and examples.

License

MIT; see LICENSE.

Metadata

Release files for bexar 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 bexar 0.1.0
File Size Uploaded Provenance Actions
bexar-0.1.0.tar.gz 75.0 kB Without provenance Details for bexar-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 157.2 kB

Release files / bexar-0.1.0.tar.gz

Download URL bexar-0.1.0.tar.gz
Size 75.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5d18c0e28927975ccf2a1a148e558a2b5ade6cf0de4acd820716658e44cd35f3
BLAKE2b-256 checksum
How to use checksums
7d25064a76e545262e1b903c668734b8ae056fd727ba568a7818834b848cc529
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

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

Download URL bexar-0.1.0-py3-none-any.whl
Size 82.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b4e65766637f8253bab9acd6c9516e232a11390683b0b89085555afd0781e3f
BLAKE2b-256 checksum
How to use checksums
500b08abbd264d82fd88a0516c963795c529b969c90372a96b3622a29cb4980c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for bexar 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