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.
```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
encon-cli
: a command line tool for interacting with encon JSON filesencon-js
: an npm package (npm install encon
)All crates licensed as MIT