#keepass #password #kdbx #read-write #file-format

bin+lib keepass-db

KeePass password database library and tools

2 releases

0.0.2 Oct 1, 2023
0.0.1 Sep 12, 2023

#2355 in Cryptography

MIT license

255KB
6.5K SLoC

KeePass-DB: KeePass database for KBD and KBDX file formats

KeePass-DB GitHub Actions KeePass-DB on crates.io KeePass-DB on docs.rs Chat codecov.io dependency status License file

Read and write KeePass password databases. This should be able to read all known versions supported by the official KeePass software package and as well as a few variants only supported via extensions.

Write support is currently experimental.

Example code

To find and print a password based on website URL:

use keepass_db::{KeePassDoc, protected_stream::CipherValue, Key};
fn main() -> Result<(), Error> {
    let mut key = Key::new();
    key.set_user_password("secret");
    let mut doc = KeePassDoc::load_file("passwords.kdbx", &key)?;
    let database = doc.file;
    let stream = &mut doc.cipher;
    let basic_entry = database.root_group().all_entries().filter(|e| e.url().unprotect(stream).unwrap() == "https://www.example.com/").last().unwrap();
    println!("Password: {}", basic_entry.password().unprotect(stream).unwrap());
    Ok(())
}

Crate features

Default features:

  • argonautica: Default, well-tested Argon2 implementation

Optional features:

  • rust-argon2: Original Argon2 support. Not recommended. Must not be enabled with other Argon2 features.
  • argon2-kdf: Original C implementation of Argon2. Must not be enabled with other Argon2 features.
  • write: Experimental: Enable write support for KeePass database.

Rust version requirements

The Minimum Supported Rust Version (MSRV) is currently Rust 1.70.0.

The MSRV is explicitly tested in CI. It may be bumped in minor releases, but this is not done lightly.

License

This project is licensed under

Dependencies

~15–27MB
~494K SLoC