...
 
Commits (2)
# Changelog
## 0.2.2
* Documentation additions/corrections
## 0.2.1
* Actually remove APIs listed as removed in 0.2.0
......
[package]
name = "kdbx-rs"
version = "0.2.1"
version = "0.2.2"
authors = ["Tony Finn <[email protected]>"]
edition = "2018"
description = "Keepass 2 (KDBX) password database parsing and creation"
......
......@@ -6,7 +6,7 @@ Library for reading and writing KDBX libraries from Rust.
## Example code
Obtaining the first password in the password database:
Obtaining an entry from the password database:
```rust
use kdbx_rs::{self, CompositeKey, Error};
......@@ -16,7 +16,11 @@ fn main() -> Result<(), Error> {
let key = CompositeKey::from_password("kdbxrs");
let unlocked = kdbx.unlock(&key)?;
println!(unlocked.root().entries[0].password())
let password = unlocked.find_entry(|e| e.url() == Some("https://example.com"))
.unwrap()
.password();
println!(password);
Ok(())
}
```
......
......@@ -178,7 +178,7 @@ When the AES KDF is used, the following parameters are read from the KDF paramet
* "S" - The key used for the cipher
For KDBX 3.1, these are read from the `TransformRounds` / `TransformSeed` parameters
in the outer head instead.
in the outer header instead.
The key is derived as follows:
......@@ -192,7 +192,7 @@ The key is derived as follows:
#### Cipher Key
The cipher key is used for encrypting/decrypting the database. It is calculated as
`sha512(master seed, master key)`.
`sha256(master seed, master key)`.
#### HMAC Key - KDBX 4+
......
//! .kdbx files and the outer binary format
//! .kdbx archives and the outer binary format
//!
//! Most methods are available on a specific state like `Kdbx<Locked>`
//! or `Kdbx<Unlocked>`.
//!
//! A keepass 2 archive can be obtained in one of two ways. You may read
//! an existing archive using [`kdbx_rs::open`][crate::open] or
//! [`kdbx_rs::from_reader`][crate::from_reader].
//!
//! You can also create a password database using [`Database`][crate::Database],
//! then turn it into a KeePass 2 archive using [`Kdbx::from_database`].
pub(crate) mod errors;
mod header;
......
#![deny(missing_docs)]
//! Module to read and write KDBX (Keepass 2) database files.
//! Module to read and write KDBX (Keepass 2) databases.
//!
//! The main types in this crate are:
//!
//! * [`Database`] which represents a password database
//! * [`Kdbx`] which represents a database file, including encryption options
//! * [`Kdbx`] which represents a database archive, including encryption options
//!
//! # Opening a database
//!
......
......@@ -5,6 +5,6 @@ pub(crate) mod parse;
pub(crate) mod serialize;
pub use crate::stream::random::InnerStreamError;
pub use decoders::{decode_datetime, decode_uuid};
pub use decoders::{decode_datetime, decode_uuid, encode_datetime, encode_uuid};
pub use parse::parse_xml;
pub use serialize::write_xml;
......@@ -37,11 +37,13 @@ pub fn decode_datetime(strdate: &str) -> Option<NaiveDateTime> {
}
}
pub(crate) fn encode_uuid(uuid: Uuid) -> String {
/// Encode a UUID for a Keepass XML file for kdbx4
pub fn encode_uuid(uuid: Uuid) -> String {
base64::encode(uuid.as_bytes())
}
pub(crate) fn encode_datetime(date: NaiveDateTime) -> String {
/// Encode a datetime for a Keepass XML file for kdbx4
pub fn encode_datetime(date: NaiveDateTime) -> String {
let epoch_seconds = date.signed_duration_since(keepass_epoch()).num_seconds();
base64::encode(epoch_seconds.to_le_bytes())
}