KDBX-rs

Documentation | Repository | crates.io

Library for reading and writing KDBX libraries from Rust.

Example code

Obtaining the first password in the password database:

```rust use kdbxrs::{self, CompositeKey, Error}; fn main() -> Result<(), Error> { let filepath = "./res/testinput/kdbx4-argon2.kdbx"; let kdbx = kdbxrs::open(filepath)?; let key = CompositeKey::frompassword("kdbxrs"); let unlocked = kdbx.unlock(&key)?;

println!(unlocked.root().entries[0].password())
Ok(())

} ```

Generating a new password database:

```rust let mut database = Database::default(); database.setname("My First Database"); database.setdescription("Created with kdbx-rs");

let mut entry = Entry::default(); entry.setpassword("password1"); entry.seturl("https://example.com"); entry.set_username("User123");

database.add_entry(Entry); ```

Saving a database to a file

```rust let kdbx = Kdbx::fromdatabase(database); kdbx.setkey(CompositeKey::from_password("foo123"))?;

let mut file = File::create("/tmp/kdbx-rs-example.kdbx")?; kdbx.write(&mut file)?; ```

Comparison of Rust Keepass Libraries (as of May 2020)

| |[kdbx-rs]|[keepass-rs]| [kdbx4] |[rust-kpdb]|[rust-keepass]| |------------------|-----------|--------------|-----------|-------------|----------------| | License | GPLv3+ | MIT | MIT | MIT/Apache | ISC | | Formats | | | | | | | .kdbx 4 | Yes | Read only | Read only | No | No | | .kdbx 3 | No | Read only | No | Yes | No | | .kdb | No | No | No | No | Yes | | Algorithms | | | | | | | KDFS | | | | | | | AES | Yes | Yes | Yes | Yes | Yes | | Argon 2 | Yes | Yes | Yes | No | Yes | |Database Ciphers| | | | | | | AES | Yes | Yes | Yes | Yes | Yes | | TwoFish | Yes | Yes | No | Yes | No | | Chacha20 | Yes | Yes | Yes | No | No | | Value Ciphers | | | | | | | Chacha20 | Yes | Yes | Yes | No | No | | Salsa20 | Yes | Yes | Yes | Yes | No | | Features | | | | | | | Memory protection| No | Yes | No | No | Yes | | Keyfile auth | Yes | Yes | Yes | Yes | Yes | | Windows auth | No | No | No | No | No | | KeepassXC OTPs | No | No | No | No | No | | Custom fields | Yes | Yes | Yes | No | No | | Entry History | Yes | No | Yes | Yes | No |

License

This crate is licensed under GPLv3.0 or later, see LICENSE.txt for details.