Rust-kpdb
A Rust library for reading and writing KeePass 2 and KeePassX databases.
Usage
To use rust-kpdb
, add the following to your Cargo.toml:
[]
= "0.5"
And the following to your crate root:
extern crate kpdb;
Examples
Create a new database adding two groups and two entries:
use ;
// Create a new database.
let key = from_password;
let mut db = new;
// Create a new group named Email.
let mut email_group = new;
let email_group_uuid = email_group.uuid;
// Create an entry for ProtonMail and add it to the Email group.
let mut protonmail = new;
let protonmail_uuid = protonmail.uuid;
protonmail.set_title;
protonmail.set_username;
protonmail.set_password;
protonmail.set_url;
email_group.add_entry;
// Create a new group named VPN.
let mut vpn_group = new;
// Create an entry for ProtonVPN and add it to the VPN group.
let mut protonvpn = new;
protonvpn.set_title;
protonvpn.set_username;
protonvpn.set_password;
protonvpn.set_url;
vpn_group.add_entry;
// Add the Email and VPN groups to the Root group.
db.root_group.add_group;
db.root_group.add_group;
// Find groups matching "email".
let groups = db.find_groups;
assert_eq!;
// Find entries matching "proton".
let entries = db.find_entries;
assert_eq!;
// Retrieve a group by its UUID.
let group = db.get_group.unwrap;
assert_eq!;
// Retrieve an entry by its UUID.
let entry = db.get_entry.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Open the existing KeePass database passwords.kdbx using the password "password", print it and save it to new.kdbx:
use ;
use File;
let mut file = open.unwrap;
let key = from_password;
let db = open.unwrap;
println!;
let mut file = create.unwrap;
db.save.unwrap;
Open the existing KeePass database passwords.kdbx using both the password "password" and the key file passwords.key, print it and save it to new.kdbx:
use ;
use File;
let mut file = open.unwrap;
let key_file = open.unwrap;
let key = from_both;
let mut file = open.unwrap;
let db = open.unwrap;
println!;
let mut file = create.unwrap;
db.save.unwrap;
Not Implemented
The following features are currently not implemented:
- KeePass 1 databases.
License
Rust-kpdb is dual licensed under the MIT and Apache 2.0 licenses, the same licenses as the Rust compiler.
Contributions
Contributions are welcome. By submitting a pull request you are agreeing to make you work available under the license terms of the Rust-kpdb project.