Crate crypto_vault [−] [src]
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()); }
Structs
RawVault |
Stores the data in an encrypted format. The only information needed to decrypt the data should be the password. |
Vault |
Stores the decrypted data. May have the master key and salt for encryption. |
Enums
VaultError |
Various errors for vault operations |
Traits
DecryptVault |
Helper methods for decrypting objects |
VaultObject |
An alias type for Decodable + Encodable + Debug |
Type Definitions
VResult |
Convenience type for VaultError functions |