3 releases
Uses old Rust 2015
0.0.3 | Jul 2, 2015 |
---|---|
0.0.2 | Jul 1, 2015 |
0.0.1 | Jul 1, 2015 |
#13 in #decrypt
10KB
194 lines
crypto_vault
A simple library for an encrypted vault of objects
lib.rs
:
A simple vault for storing encrypted data.
View the project on Github.
Usage
extern crate rustc_serialize;
extern crate crypto_vault;
use rustc_serialize::{Decoder, Encoder};
use crypto_vault::{Vault, RawVault, DecryptVault};
use std::str::FromStr;
#[derive(RustcEncodable, RustcDecodable, Debug)]
struct Obj {
key: String
}
fn main() {
let mut vault = Vault::new().with_password("foo");
vault.objects.push(Obj { key: "bar".to_owned() });
let vault_str = vault.encrypt().unwrap().to_string();
// The long way
let new_vault1: Vault<Obj> = RawVault::from_str(&vault_str)
.unwrap()
.decrypt("foo")
.unwrap();
assert_eq!(new_vault1.objects[0].key, "bar".to_owned());
// The short way
let new_vault2: Vault<Obj> = vault_str.decrypt_vault("foo").unwrap();
assert_eq!(new_vault2.objects[0].key, "bar".to_owned());
}
Dependencies
~2.2–3MB
~69K SLoC