kpdb/lib.rs
1// Copyright (c) 2016-2017 Martijn Rijkeboer <[email protected]>
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9//! Library for reading and writing KeePass 2 and KeePassX databases.
10//!
11//! # Usage
12//!
13//! To use this crate, add the following to your Cargo.toml:
14//!
15//! ```toml
16//! [dependencies]
17//! rust-kpdb = "0.2.0"
18//! ```
19//!
20//! And the following to your crate root:
21//!
22//! ```rust
23//! extern crate kpdb;
24//! ```
25//!
26//! # Examples
27//!
28//! Create a new database:
29//!
30//! ```rust,no_run
31//! use kpdb::{CompositeKey, Database};
32//!
33//! let key = CompositeKey::from_password("password");
34//! let db = Database::new(&key);
35//! ```
36//!
37//! Open the KeePass database passwords.kdbx using the password "password" and
38//! print it:
39//!
40//! ```rust,no_run
41//! use kpdb::{CompositeKey, Database};
42//! use std::fs::File;
43//!
44//! fn main() {
45//! let mut file = File::open("passwords.kdbx").unwrap();
46//! let key = CompositeKey::from_password("password");
47//! let db = Database::open(&mut file, &key).unwrap();
48//! println!("{:?}", db);
49//! }
50//! ```
51//!
52//! Open the KeePass database passwords.kdbx using both the password "password"
53//! and the key file passwords.key and print it:
54//!
55//! ```rust,no_run
56//! use kpdb::{CompositeKey, Database, KeyFile};
57//! use std::fs::File;
58//!
59//! fn main() {
60//! let mut file = File::open("passwords.key").unwrap();
61//! let key_file = KeyFile::open(&mut file).unwrap();
62//! let key = CompositeKey::from_both("password", key_file);
63//!
64//! let mut file = File::open("passwords.kdbx").unwrap();
65//! let db = Database::open(&mut file, &key).unwrap();
66//! println!("{:?}", db);
67//! }
68//! ```
69//!
70//! Save a new KeePass database to new.kdbx:
71//!
72//! ```rust,no_run
73//! use kpdb::{CompositeKey, Database};
74//! use std::fs::File;
75//!
76//! fn main() {
77//! let key = CompositeKey::from_password("password");
78//! let db = Database::new(&key);
79//! let mut file = File::create("new.kdbx").unwrap();
80//! db.save(&mut file).unwrap();
81//! }
82//! ```
83//!
84//! # Not Implemented
85//!
86//! The following features are currently not implemented:
87//!
88//! - KeePass 1 databases.
89
90
91extern crate base64;
92extern crate byteorder;
93extern crate chrono;
94extern crate crypto as rust_crypto;
95extern crate flate2;
96extern crate hex;
97extern crate rand;
98extern crate secstr;
99extern crate uuid;
100extern crate xml;
101
102pub use types::Association;
103pub use types::BinariesMap;
104pub use types::BinaryId;
105pub use types::BinaryKey;
106pub use types::BinaryValue;
107pub use types::Comment;
108pub use types::CompositeKey;
109pub use types::Compression;
110pub use types::CustomDataMap;
111pub use types::CustomIconUuid;
112pub use types::CustomIconsMap;
113pub use types::Database;
114pub use types::DbType;
115pub use types::EntriesMap;
116pub use types::Entry;
117pub use types::EntryUuid;
118pub use types::Error;
119pub use types::Group;
120pub use types::GroupUuid;
121pub use types::GroupsMap;
122pub use types::HistoryMap;
123pub use types::KeyFile;
124pub use types::KeyFileType;
125pub use types::MasterCipher;
126pub use types::Result;
127pub use types::StreamCipher;
128pub use types::StringKey;
129pub use types::StringValue;
130pub use types::StringsMap;
131pub use types::TransformRounds;
132pub use types::Version;
133pub use types::{Color, ColorError};
134pub use types::{Icon, IconError};
135pub use types::{Obfuscation, ObfuscationError};
136
137mod common;
138mod compression;
139mod crypto;
140mod format;
141mod io;
142mod types;
143mod utils;
144
145
146#[cfg(test)]
147#[macro_use]
148extern crate quickcheck;