encon

Encon is an optionally-encrypted config format, built on top of JSON. A mix of encrypted and plain fields, and support for encrypting arbitrary JSON values make it very flexible.

Example

```rust use serde_json::json; use encon::{Password, Map, Encryptable};

let pass = Password::new("strongpassword");

let mut map = Map::new(); map.insert("foo", Encryptable::Plain("Foo".into())); map.insert("bar", Encryptable::Plain("Bar".into())); map.getmut(&"foo".toowned()).unwrap().intend_encrypted();

asserteq!(map.get(&"foo".toowned()).unwrap().isencrypted(), false); asserteq!(map.get(&"bar".toowned()).unwrap().isencrypted(), false);

map.applyallintents(&pass).unwrap(); asserteq!(map.get(&"foo".toowned()).unwrap().isencrypted(), true); asserteq!(map.get(&"bar".toowned()).unwrap().isencrypted(), false);

let json = map.tojsonpretty().unwrap(); let mut map2: Map = serdejson::fromstr(&json).unwrap(); asserteq!(map2.get(&"foo".toowned()).unwrap().isencrypted(), true); asserteq!(map2.get(&"bar".toowned()).unwrap().isencrypted(), false);

let value = map2.getmut(&"foo".toowned()).unwrap() .todecrypted(&pass).unwrap() .asplain().unwrap().clone(); assert_eq!(value, json!("Foo")); ```

Current version: 0.0.1

Other Crates

All crates licensed as MIT