Skip to main content

aes-env-crypt

Keep a small JSON dict of secrets (API keys, SAS tokens) in an AES-256 encrypted file, and decrypt it only when a script needs it: as a Python dict, as Bash export lines, or as a plain JSON file. Encryption uses pyAesCrypt, its only dependency.

pip install aes-env-crypt        # or: uv add aes-env-crypt

Python

from aes_env_crypt import aesCryptJson

aesCryptJson('service.aes', password).encrypt({'API_TOKEN': '...'})
secrets = aesCryptJson('service.aes', password).decrypt()   # -> dict

A wrong password or a corrupt file raises ValueError.

Command line

Command Does
args-to-aes-file -f NAME -p PASSWORD -d VAR=value ... writes NAME.aes
env-from-aes-file -f NAME.aes -p PASSWORD prints export VAR="value" lines (names upper-cased)
json-from-aes-file -f NAME.aes -p PASSWORD writes plain-text NAME.json next to the file

Load secrets into the current Bash shell without echoing the password:

read -rsp 'Password: ' pw; echo
eval "$(env-from-aes-file -f service.aes -p "$pw")"; unset pw

Security notes

  • -p puts the password on the command line, where other local users can see it in the process list while the command runs. Prefer the Python API on shared hosts.
  • Keep .aes files out of git. An encrypted file in a repository can be attacked offline forever, so its safety then rests only on the password strength.
  • json-from-aes-file writes the secrets unencrypted; delete the .json after use.

Development

uv run --isolated --no-project --with-editable . python -m unittest discover -s tests -v
uv build && uvx twine check dist/*

CI (.github/workflows/ci.yml) runs the tests on Python 3.10 to 3.14 for every push to main and every pull request.

Releasing

Publish to PyPI (.github/workflows/publish.yml) runs when a v* tag is pushed. It checks that the tag matches the pyproject.toml version, runs the tests, builds, and uploads to PyPI with Trusted Publishing, so no PyPI token is stored in GitHub.

uv version --bump patch        # or set the version in pyproject.toml
git commit -am "Release vX.Y.Z" && git tag vX.Y.Z && git push origin main vX.Y.Z

One-time setup before the first release:

  1. On pypi.org, go to Account settings → Publishing → Add a new pending publisher, and enter: PyPI project aes-env-crypt, owner idanre1, repository aes_env_crypt, workflow publish.yml, environment pypi.
  2. On GitHub, go to repository Settings → Environments → New environment and create pypi. Optionally add yourself as a required reviewer, so each upload waits for your approval.

Formerly azure_env_crypt; its Azure CLI helpers moved out, so the package no longer depends on Azure.

License

GPL-3.0-only. See LICENSE.

Metadata

Release files for aes-env-crypt 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 aes-env-crypt 0.1.0
File Size Uploaded Provenance Actions
aes_env_crypt-0.1.0.tar.gz 17.6 kB With provenance Details for aes_env_crypt-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 35.1 kB

Release files / aes_env_crypt-0.1.0.tar.gz

Download URL aes_env_crypt-0.1.0.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
edcc05678657daa158f44b1f0082ad782dc05c6d7d4492e952240d934f4527c1
BLAKE2b-256 checksum
How to use checksums
16a2bc9fd2751c3ff80ad326f4d0f87ce6d6dcab5d3b15f558e282feac2df098
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

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

Download URL aes_env_crypt-0.1.0-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9326ac0351f2a120f30e6ac29ce929cb5f13de11ca467e1aba58e3e83005de0a
BLAKE2b-256 checksum
How to use checksums
90c9194373c51fcb50ba0c2eb7f1ed0fa4b5a2e6d86a959badc6b564a188c892
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for aes-env-crypt 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aes_env_crypt-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

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 Full 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