Skip to main content

Encrypted secrets management for Python applications

Project description

VibeLock Python SDK v1

Cross-platform secrets management for Python applications, encrypted with VibeLock.

Status: Core implementation complete — crypto, vault, master key, SDK, CLI, and interoperability tests done.


Features

  • AES-256-GCM encryption with 600k PBKDF2-SHA512 iterations
  • File-based master key storage with atomic operations
  • Configurable master key path (keys_path / VIBELOCK_KEYS_PATH)
  • 100% compatible with VibeLock TypeScript SDK
  • Simple async API: init(), set(), get(), list(), remove()
  • Multi-project isolation
  • Atomic vault operations

Quick Start

import vibelock
import asyncio

async def main():
    # Initialize new vault
    await vibelock.init()
    
    # Store secrets
    await vibelock.set("API_KEY", "sk-abc123def456")
    await vibelock.set("DATABASE_URL", "postgresql://user:pass@localhost/db")
    
    # Retrieve secrets
    api_key = await vibelock.get("API_KEY")
    db_url = await vibelock.get("DATABASE_URL")
    
    # List all secrets
    secrets = await vibelock.list()
    print(f"Available secrets: {secrets}")

if __name__ == "__main__":
    asyncio.run(main())

Installation

# Install from PyPI (when released)
pip install vibelock

# Install from source
git clone https://github.com/ismaibz/vibelock.git
cd vibelock/python-sdk
pip install -e .

API Reference

vibelock.init(options=None)

Initialize a new vault with master key.

async def init(options: VibeLockOptions = None) -> None:

Parameters:

  • options (VibeLockOptions, optional): Configuration options
    • vault_path (str): Path to vault file (default: "./secrets.vibe")
    • project_id (str): Project identifier (default: "default")
    • keys_path (str, optional): Custom master key storage directory

Raises:

  • FileExistsError: If vault or master key already exists

vibelock.set(key, value, options=None)

Encrypt and store a secret.

async def set(key: str, value: str, options: VibeLockOptions = None) -> None:

vibelock.get(key, options=None)

Decrypt and retrieve a secret.

async def get(key: str, options: VibeLockOptions = None) -> str:

vibelock.list(options=None)

List all secret names.

async def list(options: VibeLockOptions = None) -> list[str]:

vibelock.remove(key, options=None)

Delete a secret.

async def remove(key: str, options: VibeLockOptions = None) -> None:

Configuration

VibeLockOptions

@dataclass
class VibeLockOptions:
    vault_path: str = "./secrets.vibe"
    project_id: str = "default"
    keys_path: Optional[str] = None

Custom Keys Path

# Store master keys in a custom location
options = vibelock.VibeLockOptions(
    project_id="production",
    vault_path="./production.secrets",
    keys_path="/etc/vibelock/keys"
)

# Or via environment variable
import os
os.environ["VIBELOCK_KEYS_PATH"] = "/etc/vibelock/keys"

Example

import asyncio
from vibelock import get, get_env
from vibelock.config import VibeLockOptions

opts = VibeLockOptions(
    project_id="my-app",
    vault_path="./secrets.vibe"
)

async def main():
    # Retrieve an encrypted secret
    api_key = await get("API_KEY", options=opts)
    
    # Retrieve plaintext configuration
    db_url = await get_env("DB_URL", options=opts)
    
    print(f"Connecting to {db_url} with API key...")

asyncio.run(main())

Multi-Project Example

# Production vault
prod_options = vibelock.VibeLockOptions(
    project_id="production",
    vault_path="./secrets.prod.vibe"
)

# Staging vault  
staging_options = vibelock.VibeLockOptions(
    project_id="staging",
    vault_path="./staging.secrets"
)

await vibelock.set("API_KEY", "prod-key-123", prod_options)
await vibelock.set("API_KEY", "staging-key-456", staging_options)

prod_key = await vibelock.get("API_KEY", prod_options)
staging_key = await vibelock.get("API_KEY", staging_options)

Security Features

Encryption

  • Algorithm: AES-256-GCM
  • Key Derivation: PBKDF2-SHA512 with 600,000 iterations
  • IV Length: 12 bytes (24 hex chars)
  • Auth Tag: 16 bytes (32 hex chars)

Storage

  • Master Key: 32 bytes random, stored as file
  • File Permissions: 0o600 for keys, 0o700 for directories
  • Vault Format: JSON with atomic writes
  • Per-Salt: Each secret gets unique salt for forward security

Key Path Resolution

  1. keys_path option (explicit)
  2. VIBELOCK_KEYS_PATH environment variable
  3. Default: ~/.vibelock/keys/

Interoperability

The Python SDK is 100% compatible with the TypeScript SDK:

# Python and TypeScript SDKs can read each other's vaults
await vibelock.set("SHARED_SECRET", "cross-platform-value")

# TypeScript SDK can read: await get("SHARED_SECRET")
# Python SDK can read: await vibelock.get("SHARED_SECRET") 

Vault Format: Identical JSON structure, encoding, and cryptographic operations.


Development

Running Tests

# All tests
pytest

# With coverage
pytest --cov=vibelock

# Specific test categories
pytest tests/test_crypto.py
pytest tests/interoperability/

Code Quality

# Format code
black .

# Lint code  
ruff check .

# Type checking
mypy src/

Contributing

  1. Fork the repository
  2. Create feature branch
  3. Add tests for new functionality
  4. Ensure all linting checks pass
  5. Submit pull request

Architecture

src/vibelock/
├── __init__.py          # Public API exports
├── crypto.py            # AES-256-GCM, PBKDF2-SHA512
├── vault.py             # Vault JSON operations  
├── masterkey.py         # File-based key management
└── sdk.py               # High-level API coordination

Implementation Phases

  1. Crypto: Core cryptographic primitives
  2. Vault: JSON file operations and validation
  3. Master Key: Storage and retrieval
  4. SDK: Public API coordination
  5. Interoperability: Cross-SDK compatibility
  6. Packaging: Distribution and documentation

License

MIT License - see LICENSE file for details.

Issues

Report bugs and request features on GitHub Issues.


Support


VibeLock - Secrets management for developers, encrypted and portable.

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

vibelock-1.0.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

vibelock-1.0.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file vibelock-1.0.0.tar.gz.

File metadata

  • Download URL: vibelock-1.0.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vibelock-1.0.0.tar.gz
Algorithm Hash digest
SHA256 979194ad04d2bd6c0c084b7a3e65a45b24b6b93922b188ba83601fc89d0d5c5e
MD5 41523eea90e7bfe8673c3bdfbce72b5f
BLAKE2b-256 f93c6b8f8023474070a7e058fbdb99352601163bd2c3befca96d2042bbc44bc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for vibelock-1.0.0.tar.gz:

Publisher: release-python.yml on irequena-dev/VibeLock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vibelock-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: vibelock-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vibelock-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26173dfb4d844702aeb1cae5320bc4255ba1414856c7d7f84da5bf0b6f2fcc98
MD5 ff12fb061bae295f19ef8fc71c05fd39
BLAKE2b-256 4e214fba026918eb19ab8815c1192f2af65239368dad12936f14553037a0a490

See more details on using hashes here.

Provenance

The following attestation bundles were made for vibelock-1.0.0-py3-none-any.whl:

Publisher: release-python.yml on irequena-dev/VibeLock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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