Skip to main content

A modern, secure Python library for reading and writing KeePass KDBX databases

Project description

kdbxtool

CI Coverage mypy Docs Python 3.12+ License

A modern, secure Python library for reading and writing KeePass KDBX databases.

Features

  • Secure by default: Memory zeroization, constant-time comparisons, hardened XML parsing
  • Type-safe: Full type hints, Python 3.12+ features, mypy strict compatible
  • Modern API: Clean, Pythonic interface with context manager support
  • KDBX4 focused: First-class support for modern KeePass format with Argon2
  • Multiple ciphers: AES-256-CBC, ChaCha20, and Twofish-256-CBC (optional)

Installation

pip install kdbxtool

Optional: Twofish Support

For legacy databases encrypted with Twofish-256-CBC:

pip install kdbxtool[twofish]

This installs oxifish, a Rust-based Twofish implementation.

Optional: YubiKey Support

For hardware-backed authentication with YubiKey HMAC-SHA1 challenge-response:

pip install kdbxtool[yubikey]

This installs yubikey-manager for YubiKey communication.

Quick Start

from kdbxtool import Database

# Open a database with context manager
with Database.open("vault.kdbx", password="my-password") as db:
    # Find entries
    entries = db.find_entries(title="Gmail")
    if entries:
        print(f"Username: {entries[0].username}")

    # Create new entries
    db.root_group.create_entry(
        title="New Account",
        username="user@example.com",
        password="secure-password",
    )

    db.save()

# Create a new database
db = Database.create(password="my-password", database_name="My Vault")
db.root_group.create_entry(title="First Entry", username="me", password="secret")
db.save("my-vault.kdbx")

YubiKey Support

kdbxtool supports YubiKey HMAC-SHA1 challenge-response authentication, compatible with KeePassXC:

from kdbxtool import Database
from kdbxtool.security import list_yubikeys, is_yubikey_available

# Check YubiKey availability
if is_yubikey_available():
    devices = list_yubikeys()
    for device in devices:
        print(f"Found: {device['name']} (serial: {device.get('serial', 'N/A')})")

# Open a YubiKey-protected database
with Database.open("vault.kdbx", password="my-password", yubikey_slot=2) as db:
    print(f"Entries: {len(db.find_entries())}")
    db.save()

# Create a new database with YubiKey protection
db = Database.create(
    password="my-password",
    yubikey_slot=2,           # Use slot 2 (recommended)
    yubikey_serial=12345678,  # Optional: specific YubiKey serial
)
db.save("protected.kdbx")

# Open with specific YubiKey when multiple are connected
with Database.open(
    "vault.kdbx",
    password="my-password",
    yubikey_slot=2,
    yubikey_serial=12345678,
) as db:
    pass

Requirements:

  • YubiKey with HMAC-SHA1 configured in slot 1 or 2
  • Configure with: ykman otp chalresp -g 2 (generates random secret for slot 2)

Security

kdbxtool prioritizes security:

  • SecureBytes: Sensitive data is stored in zeroizable buffers
  • Constant-time comparisons: All authentication uses hmac.compare_digest
  • Hardened XML: Uses defusedxml to prevent XXE attacks
  • Modern KDF: Enforces minimum Argon2 parameters

License

Apache-2.0

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

kdbxtool-0.1.5.tar.gz (196.8 kB view details)

Uploaded Source

Built Distribution

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

kdbxtool-0.1.5-py3-none-any.whl (70.5 kB view details)

Uploaded Python 3

File details

Details for the file kdbxtool-0.1.5.tar.gz.

File metadata

  • Download URL: kdbxtool-0.1.5.tar.gz
  • Upload date:
  • Size: 196.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kdbxtool-0.1.5.tar.gz
Algorithm Hash digest
SHA256 eb4f04cdb8f09925154f1001eec3a37ed9d52b222b9059086d1415c0eb300535
MD5 b35a4dd30d8b89d76ac9a5ac08220576
BLAKE2b-256 2029edf3c4a55472e744bebafb97dff5e69a6ccb1f913bcf871cd26e4538cc7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for kdbxtool-0.1.5.tar.gz:

Publisher: release.yml on coreyleavitt/kdbxtool

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

File details

Details for the file kdbxtool-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: kdbxtool-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 70.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kdbxtool-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 457ccd4d3ec8a5d0a24c9f56b6384585aab6bb33b4dcf9e464bd95afd618b53c
MD5 14d4d776f8628319b797777bcbdb0ea4
BLAKE2b-256 e81a320edc1e19248a690996065770089ba3b6f7c46a45768ffecfabf7c17325

See more details on using hashes here.

Provenance

The following attestation bundles were made for kdbxtool-0.1.5-py3-none-any.whl:

Publisher: release.yml on coreyleavitt/kdbxtool

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