Crate kpdb [] [src]

Library for reading and writing KeePass 2 and KeePassX databases.

Usage

To use this crate, add the following to your Cargo.toml:

[dependencies]
rust-kpdb = "0.1.0"

And the following to your crate root:

extern crate kpdb;

Examples

Create a new database:

use kpdb::{CompositeKey, Database};

let key = CompositeKey::from_password("password");
let db = Database::new(&key);

Open the KeePass database passwords.kdbx using the password "password" and print it:

use kpdb::{CompositeKey, Database};
use std::fs::File;

fn main() {
    let mut file = File::open("passwords.kdbx").unwrap();
    let key = CompositeKey::from_password("password");
    let db = Database::open(&mut file, &key).unwrap();
    println!("{:?}", db);
}

Open the KeePass database passwords.kdbx using both the password "password" and the key file passwords.key and print it:

use kpdb::{CompositeKey, Database, KeyFile};
use std::fs::File;

fn main() {
    let mut file = File::open("passwords.key").unwrap();
    let key_file = KeyFile::open(&mut file).unwrap();
    let key = CompositeKey::from_both("password", key_file);

    let mut file = File::open("passwords.kdbx").unwrap();
    let db = Database::open(&mut file, &key).unwrap();
    println!("{:?}", db);
}

Save a new KeePass database to new.kdbx:

use kpdb::{CompositeKey, Database};
use std::fs::File;

fn main() {
    let key = CompositeKey::from_password("password");
    let db = Database::new(&key);
    let mut file = File::create("new.kdbx").unwrap();
    db.save(&mut file).unwrap();
}

Not Implemented

The following features are currently not implemented:

  • KeePass 1 databases.

Structs

Association

An auto-type association.

BinaryId

An identifier for binaries in the global binaries map.

BinaryKey

A key for binaries in entry's binaries map.

Color

A structure representing a color (RGB).

Comment

The binary comment header from the database file.

CompositeKey

Composition of the user's key data.

CustomIconUuid

The identifier for a custom icon.

Database

The KeePass database.

Entry

An entry in the database.

EntryUuid

The identifier for an entry.

Group

A group in the database.

GroupUuid

The identifier for a group.

KeyFile

A key file used for encrypting and decrypting the database.

TransformRounds

Number of times the composite key must be transformed.

Version

The database version.

Enums

BinaryValue

A value for entry's map with binaries.

ColorError

Error type for color conversion errors.

Compression

The compression algorithm.

DbType

The database type.

Error

Error type for database errors.

Icon

The icon of an entry or group.

IconError

Error type for icon conversion errors.

KeyFileType

The type of the key file.

MasterCipher

The encryption algorithm for the master data.

Obfuscation

The type of obfuscation to use.

ObfuscationError

Error type for obfuscation conversion errors.

StreamCipher

The encryption algorithm for the stream data (e.g. passwords).

StringKey

A key for the map with strings.

StringValue

A value for the map with strings.

Type Definitions

BinariesMap

A type alias for the global map with binaries.

CustomDataMap

A type alias for a map with custom data.

CustomIconsMap

A type alias for a map with custom icons.

EntriesMap

A type alias for a map with entries.

GroupsMap

A type alias for a map with groups.

HistoryMap

A type alias for a map with history entries.

Result

A specialized result type for database operations.

StringsMap

A type alias for the map with strings.