chore: piv, pivsign

This commit is contained in:
2022-03-27 12:04:41 +08:00
parent e60feacf37
commit f996dc7570
2 changed files with 18 additions and 9 deletions

View File

@@ -29,8 +29,6 @@ impl Command for CommandImpl {
let cipher = sub_arg_matches.value_of("cipher");
let cipher_base64 = sub_arg_matches.value_of("cipher-base64");
let mut json = BTreeMap::<&'_ str, String>::new();
let cipher_bytes = if let Some(cipher) = cipher {
opt_result!(hex::decode(cipher), "Decode cipher failed: {}")
} else if let Some(cipher_base64) = cipher_base64 {
@@ -44,18 +42,16 @@ impl Command for CommandImpl {
success!("Clear text HEX: {}", hex::encode(&text));
success!("Clear text base64: {}", base64::encode(&text));
success!("Clear text UTF-8: {}", String::from_utf8_lossy(&text));
if json_output {
let mut json = BTreeMap::<&'_ str, String>::new();
json.insert("cipher_hex", hex::encode(&cipher_bytes));
json.insert("cipher_base64", base64::encode(&cipher_bytes));
json.insert("text_hex", hex::encode(&text));
json.insert("text_utf8", String::from_utf8_lossy(&text).to_string());
}
if json_output {
println!("{}", serde_json::to_string_pretty(&json).unwrap());
}
Ok(None)
}
}