Skip to content

jgrussell/keepass-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

keepass

Crates.io Documentation Build Status codecov

KeePass .kdbx database file parser for Rust

Example

extern crate keepass;

use keepass::{Database, Node, Result, Error};
use std::fs::File;

fn main() -> Result<()> {
    // Open KeePass database
    let path = std::path::Path::new("tests/resources/test_db_with_password.kdbx");
    let db = Database::open(
        &mut File::open(path)?,         // the database
        Some("demopass"),               // password
        None                            // keyfile
    )?;

    // Iterate over all Groups and Nodes
    for node in &db.root {
        match node {
            Node::Group(g) => {
                println!("Saw group '{0}'", g.name);
            },
            Node::Entry(e) => {
                let title = e.get_title().unwrap();
                let user = e.get_username().unwrap();
                let pass = e.get_password().unwrap();
                println!("Entry '{0}': '{1}' : '{2}'", title, user, pass);
            }
        }
    }

    Ok(())
}

Installation

Add the following to the dependencies section of your Cargo.toml:

[dependencies]
keepass = "*"

Performance note: Please set the RUSTFLAGS environment variable when compiling to enable CPU-specific optimizations (this greatly affects the speed of the AES key derivation):

export RUSTFLAGS='-C target-cpu=native'

For best results, also compile in Release mode.

Alternatively, you can add a .cargo/config.toml like in this project to ensure that rustflags are always set.

License

MIT

About

KeePass kdbx database file parser

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%