Function sjcl::decryption::decrypt_json[][src]

pub fn decrypt_json(
    chunk: String,
    key: String,
    adata: Option<String>
) -> Result<Vec<u8>, SjclError>
Expand description

Decrypts a chunk of SJCL encrypted JSON with a given passphrase.

let data = "{\"iv\":\"nJu7KZF2eEqMv403U2oc3w==\", \"v\":1, \"iter\":10000, \"ks\":256, \"ts\":64, \"mode\":\"ccm\", \"adata\":\"\", \"cipher\":\"aes\", \"salt\":\"mMmxX6SipEM=\", \"ct\":\"VwnKwpW1ah5HmdvwuFBthx0=\"}".to_string();
let password_phrase = "abcdefghi".to_string();
let plaintext = sjcl::decrypt_json(data, password_phrase, None).unwrap();
assert_eq!("test\ntest".to_string(), String::from_utf8(plaintext).unwrap());