Skip to main content

agent-opaque-env

Self-describing encrypted environment files for AI-assisted development.

The package keeps environment keys and values out of plain-text repository context. Its Rust extension also raises the cost of casual static analysis. It is not a secret manager: an agent or process allowed to call load_env() can read the returned values.

Install

uv add agent-opaque-env

The wheel contains the Rust implementation. Users do not need to install cryptography or a Rust toolchain when a wheel is available for their platform.

Use

from agent_opaque_env import dump_env, load_env


dump_env({"APP_MODE": "development"}, ".env")
values = load_env(".env")

dump_env() defaults to the zero-configuration obfuscation profile. It creates an owner-only file and stores shuffled key material with the ciphertext. This prevents direct text collection but does not create a separate secret boundary.

For protection when the repository is copied without its key, use the protected profile:

from agent_opaque_env import dump_env, load_env


# Public example key only. Never use this key for real secrets.
key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
dump_env(values, ".env", profile="protected", key=key, key_id="example-local")
values = load_env(".env", key=key)

Generate a unique key for real use and keep it outside the repository. Instead of passing key=, applications may set the AGENT_OPAQUE_ENV_KEY environment variable. Missing or incorrect keys fail explicitly and never downgrade to obfuscation.

from agent_opaque_env import generate_key


key = generate_key()  # Store this outside the repository before encrypting files.

Self-describing AOE1 format

An AOE1 file is ASCII with exactly three lines:

AGENT-OPAQUE-ENV/1
{"algorithm":"AES-256-GCM","format":"AOE1","import":"agent_opaque_env","loader":"load_env","package":"https://pypi.org/project/agent-opaque-env/","profile":"obfuscation"}
{"ciphertext":"...","key_fragments":["...","...","..."],"nonce":"..."}

The fixed package URL tells a developer or agent that the agent-opaque-env PyPI distribution and its load_env API understand the file. It never contains a shell command, package-manager arguments, any other URL, environment values, or other executable instructions. Verify the dependency against the project configuration before installing anything named by an untrusted file.

Metadata bytes are authenticated as AES-GCM associated data. Unknown fields, non-canonical JSON, modified metadata, altered ciphertext, and unsupported formats are rejected.

API

dump_env(values, path=".env", *, profile="obfuscation", key=None, key_id=None)
load_env(path=".env", *, key=None) -> dict[str, str]
loads_env(data, *, key=None) -> dict[str, str]
generate_key() -> str

Only CPython 3.11 and newer are supported. New files use AOE1 exclusively; Pickle and older formats are intentionally unsupported.

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

agent_opaque_env-0.2.0-cp311-abi3-win_amd64.whl (128.3 kB view details)

Uploaded CPython 3.11+Windows x86-64

agent_opaque_env-0.2.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (216.5 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

agent_opaque_env-0.2.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (203.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

agent_opaque_env-0.2.0-cp311-abi3-macosx_11_0_arm64.whl (194.7 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file agent_opaque_env-0.2.0-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for agent_opaque_env-0.2.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5c953d37d5dbd15483e269189fe82c56a739a69427dc98984d67c243e3afe953
MD5 c3790fd8a4727323b39088dada8f711b
BLAKE2b-256 fd7d1347e11cea56a5ca2cb4098d96d89e3a25e14639ed091d513f27d0c5ceab

See more details on using hashes here.

File details

Details for the file agent_opaque_env-0.2.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for agent_opaque_env-0.2.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fca10e850057ab666e7cd5095b6468cacc46be1dda470945dae3174f2c8915fc
MD5 0e9d904a76a2977f341c38c0b48e0c3e
BLAKE2b-256 6f4cf005255843325971f0b49b025e0ef7471a253b60e1fb463bcb1397067973

See more details on using hashes here.

File details

Details for the file agent_opaque_env-0.2.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for agent_opaque_env-0.2.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e2d4cd1e584b76cd5bc58ef91d3110feeefb2b4d4f2bfef4b0feb7e377dc0a65
MD5 bff90183a520c94acdcf281cb1bec41f
BLAKE2b-256 53b876126325f88e2e7a57baf93bb5c86784e07fec2f2b655b4a229fd89fb00f

See more details on using hashes here.

File details

Details for the file agent_opaque_env-0.2.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for agent_opaque_env-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a77ad7fcfe7ce6887ad2af50ae7fa1f6e0e1e4e8a3a5e4fdceecdf081e8a023b
MD5 4b7972323dea9d080f9c015749173f3c
BLAKE2b-256 43989756b4ef0bb06a17ffbe17f604dda41641de5e772f255c873d56d140072c

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