kdbxtool
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")
Keyfile Support
kdbxtool supports all KeePass keyfile formats for two-factor authentication:
from kdbxtool import Database, create_keyfile, KeyFileVersion
# Create a new keyfile (XML v2.0 recommended)
create_keyfile("vault.keyx") # Default: XML v2.0 with hash verification
# Other formats available
create_keyfile("vault.key", version=KeyFileVersion.XML_V1) # Legacy XML
create_keyfile("vault.key", version=KeyFileVersion.RAW_32) # Raw 32 bytes
create_keyfile("vault.key", version=KeyFileVersion.HEX_64) # Hex-encoded
# Open a database with password + keyfile
with Database.open("vault.kdbx", password="my-password", keyfile="vault.keyx") as db:
print(f"Entries: {len(db.find_entries())}")
# Create a new database with keyfile protection
db = Database.create(password="my-password", keyfile="vault.keyx")
db.save("protected.kdbx")
# Keyfile-only authentication (no password)
db = Database.create(keyfile="vault.keyx")
db.save("keyfile-only.kdbx")
YubiKey Support
kdbxtool supports YubiKey HMAC-SHA1 challenge-response authentication, compatible with KeePassXC:
from kdbxtool import Database
from kdbxtool.security import list_yubikeys
# List connected YubiKeys (raises YubiKeyNotAvailableError if yubikey-manager not installed)
for device in list_yubikeys():
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
Metadata
Release files for kdbxtool 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| kdbxtool-0.1.7.tar.gz | 219.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kdbxtool-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 305.2 kB
Release files / kdbxtool-0.1.7.tar.gz
| Download URL | kdbxtool-0.1.7.tar.gz |
|---|---|
| Size | 219.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c0751e308bf779147ace821e67a710df3cb8aa7a4b8de12b60adec5b3e97f3f
|
|
BLAKE2b-256 checksum How to use checksums |
02c1360d648ac8f9fa30d1c7d2f155cf73a7c3706e105223ae0d9e657eb2966a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Jan 20, 2026.
Transparency logRelease files / kdbxtool-0.1.7-py3-none-any.whl
| Download URL | kdbxtool-0.1.7-py3-none-any.whl |
|---|---|
| Size | 85.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48c8d5c6499514ff59bd75e29c8714cacfb32bbf178bac10394ce571b29df645
|
|
BLAKE2b-256 checksum How to use checksums |
5b64906be3abdac361e5ee2e8a49bbbc0b778a35c64c7d2ee21c1db7a67b08f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Jan 20, 2026.
Transparency logSecurity for kdbxtool 0.1.7
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for kdbxtool-0.1.7.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 Jan 20, 2026.
Transparency logA 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.