You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

agenv

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agenv

Load environment variables from age-encrypted files

0.5.0
pipPyPI
Maintainers
1

agenv

A simple Python package for securely loading environment variables from age encrypted file.

Installation

Basic Installation (Decryption Only)

If you only need to decrypt files at runtime:

pip install agenv

With dotenv Support (Load Encrypted Environment Variables)

If you need to load encrypted environment variables automatically:

pip install agenv[dotenv]

[!NOTE] age must be installed separately, as there is no native Python implementation of age.

Usage

Loading Environment Variables

from agenv import load_age_env

# Decrypts and loads environment variables from a .env.age file
load_age_env(".env.age")

Decrypting and Loading YAML Data

import yaml
from agenv import decrypt

# Decrypts the .age encrypted file and loads the content as a YAML object
yaml_str = decrypt("database.yml.age")
data = yaml.safe_load(yaml_str)
print(data)

Identity Key Selection Order

agenv determines the age identity key in the following order:

  • The identity parameter provided to load_age_env()
  • The AGE_SECRET_KEY environment variable
  • The AGE_SECRET_KEY_FILE environment variable (path to key file)
  • The default key file: $HOME/.age/age.key

If no valid identity is found, decryption will fail.

License

MIT

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts