chore: pgp card decrypt

This commit is contained in:
2022-03-27 12:27:06 +08:00
parent 4be7e880c2
commit b9dbcb8f80

View File

@@ -21,11 +21,9 @@ impl Command for CommandImpl {
if json_output {
rust_util::util_msg::set_logger_std_out(false);
}
let pass = sub_arg_matches.value_of("pass");
let pass = match pass {
Some(p) => p,
None => return simple_error!("Pass must be assigned"),
};
let pass_opt = sub_arg_matches.value_of("pass");
let pass = opt_value_result!(pass_opt, "Pass must be assigned");
if pass.len() < 6 { return simple_error!("Pass length:{}, must >= 6!", pass.len()); }
let cipher = sub_arg_matches.value_of("cipher");
let cipher_base64 = sub_arg_matches.value_of("cipher-base64");
@@ -48,6 +46,7 @@ impl Command for CommandImpl {
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_base64", base64::encode(&text));
json.insert("text_utf8", String::from_utf8_lossy(&text).to_string());
println!("{}", serde_json::to_string_pretty(&json).unwrap());