Skip to main content

Encrypted secret vault for Python projects

Project description

gbkomi Encrypted secret vault for Python projects with password-based protection.

gbkomi is a small Python package for storing tokens, API keys, and other secrets in an encrypted file instead of plain text .env files.

It uses:

Argon2id for password-based key derivation AES-256-GCM for authenticated encryption A simple JSON-based vault file format This makes secret files much safer if they are copied, leaked, or accessed by someone without the password.

Features Encrypt secrets into a single vault file Password prompt from terminal when needed Non-interactive mode with environment variable password Configurable maximum number of stored secrets Integrity protection with AES-GCM Simple CLI for init, set, get, delete, list, and info Installation pip install gbkomi For development:

bash git clone https://github.com/yourusername/gbkomi.git cd gbkomi pip install -e . Why use gbkomi instead of .env A normal .env file stores secrets as plain text.

Example:

env BOT_TOKEN=123 API_KEY=abc If the file leaks, the secrets are immediately readable.

With gbkomi, the file contents are encrypted. If someone gets the vault file but does not know the password, they cannot directly read the secrets.

This improves security for local development, backups, copied project folders, and accidental file exposure.

Important security note gbkomi protects secrets at rest.

That means:

the file on disk is encrypted the file cannot be read without the password tampering is detected during decryption But during program execution, your application still needs the decrypted secret in memory.

So gbkomi is much safer than plain .env for stored files, but it does not fully protect against:

malware on the machine keyloggers memory scraping compromised hosts Vault structure The encrypted vault file itself is JSON and contains metadata plus encrypted fields.

Example vault file:

json { "magic": "GBK1", "version": 1, "salt": "...", "nonce": "...", "ciphertext": "..." } The decrypted plaintext inside the vault looks like this:

json { "_meta": { "max_secrets": 10 }, "secrets": { "BOT_TOKEN": "123456", "API_KEY": "abcdef" } } CLI usage If the gbkomi command is available in your shell:

bash gbkomi --help If not, use:

bash python -m gbkomi.cli --help Create a vault Interactive mode:

bash python -m gbkomi.cli init secrets.gbkomi This will:

ask for the password ask for maximum number of secrets use 10 if you press Enter without typing a number Create a vault with a fixed limit:

bash python -m gbkomi.cli init secrets.gbkomi --max-secrets 20 Non-interactive mode:

bash export GBKOMI_PASSWORD="your-password" python -m gbkomi.cli --no-interactive init secrets.gbkomi --max-secrets 20 Add or update a secret bash python -m gbkomi.cli set secrets.gbkomi BOT_TOKEN 123456 Read a secret bash python -m gbkomi.cli get secrets.gbkomi BOT_TOKEN Delete a secret bash python -m gbkomi.cli delete secrets.gbkomi BOT_TOKEN List secret names bash python -m gbkomi.cli list secrets.gbkomi Show vault info bash python -m gbkomi.cli info secrets.gbkomi Example output:

text max_secrets=10 count=2 Password input modes gbkomi supports two ways to provide the vault password.

  1. Interactive terminal prompt If no environment variable is set, gbkomi asks for the password using a hidden prompt.

This is good for:

local development manual terminal usage avoiding hardcoded passwords 2. Environment variable You can provide the password with an environment variable.

Default variable name:

bash GBKOMI_PASSWORD Example:

bash export GBKOMI_PASSWORD="my-secret-password" python -m gbkomi.cli --no-interactive list secrets.gbkomi You can also use another variable name:

bash export MY_VAULT_PASSWORD="my-secret-password" python -m gbkomi.cli --env-var MY_VAULT_PASSWORD --no-interactive list secrets.gbkomi Maximum secret limit Each vault stores a max_secrets value.

When creating a new vault, you can define how many secret entries it can hold.

If the vault reaches the limit:

adding a new key will fail updating an existing key will still work This is useful if you want a small fixed-size vault per bot, per project, or per deployment target.

Python usage Example:

python from gbkomi.vault import create_vault, set_secret, get_secret, list_secrets

create_vault("secrets.gbkomi", "mypassword", max_secrets=10) set_secret("secrets.gbkomi", "mypassword", "BOT_TOKEN", "123456") token = get_secret("secrets.gbkomi", "mypassword", "BOT_TOKEN") keys = list_secrets("secrets.gbkomi", "mypassword")

print(token) print(keys) Error handling Typical exceptions:

VaultFormatError VaultDecryptionError VaultLimitError Example:

python from gbkomi.vault import set_secret from gbkomi.exceptions import VaultLimitError

try: set_secret("secrets.gbkomi", "mypassword", "NEW_KEY", "value") except VaultLimitError as e: print("Vault is full:", e)

Project details


Download files

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

Source Distribution

gbkomi-0.1.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

gbkomi-0.1.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file gbkomi-0.1.1.tar.gz.

File metadata

  • Download URL: gbkomi-0.1.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for gbkomi-0.1.1.tar.gz
Algorithm Hash digest
SHA256 373250f001ee347480b4b55ec72986f15ddb580db6866b5b1dc13f5fb2d9a051
MD5 bb5c311ffdb7aa0594c4697e14566b8a
BLAKE2b-256 0239446907fa2b72330a87fe893a21bf53937b12b855f12aa23f4d7944f8c3e4

See more details on using hashes here.

File details

Details for the file gbkomi-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: gbkomi-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for gbkomi-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 54f3df0b4848df0ab17eaed349126424a6dfefaf15301a3370046813c6651b25
MD5 5fa8e8e0b9a5e3ced1e2a84c7b03f9fd
BLAKE2b-256 1ae58b931cb01088004e244d7621e4b1ba780e16d6fb42e9e44e6fb4cf5f7945

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