feat: v1.12.7
This commit is contained in:
@@ -2,7 +2,7 @@ use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
use rust_util::util_clap::{Command, CommandError};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::{cmdutil, hmacutil, util};
|
||||
use crate::{cmdutil, hmacutil, pbeutil, util};
|
||||
|
||||
pub struct CommandImpl;
|
||||
|
||||
@@ -21,6 +21,7 @@ impl Command for CommandImpl {
|
||||
.required(true)
|
||||
.help("Ciphertext"),
|
||||
)
|
||||
.arg(Arg::with_name("auto-pbe").long("auto-pbe").help("Auto PBE decryption"))
|
||||
.arg(cmdutil::build_json_arg())
|
||||
}
|
||||
|
||||
@@ -28,15 +29,20 @@ impl Command for CommandImpl {
|
||||
let json_output = cmdutil::check_json_output(sub_arg_matches);
|
||||
|
||||
let ciphertext = sub_arg_matches.value_of("ciphertext").unwrap();
|
||||
let plaintext = hmacutil::hmac_decrypt_to_string(ciphertext)?;
|
||||
let mut text = hmacutil::hmac_decrypt_to_string(ciphertext)?;
|
||||
|
||||
let auto_pbe = sub_arg_matches.is_present("auto-pbe");
|
||||
if auto_pbe && pbeutil::is_simple_pbe_encrypted(&text) {
|
||||
text = pbeutil::simple_pbe_decrypt_with_prompt_to_string(&text)?;
|
||||
}
|
||||
|
||||
if json_output {
|
||||
let mut json = BTreeMap::<&'_ str, String>::new();
|
||||
json.insert("plaintext", plaintext);
|
||||
json.insert("plaintext", text);
|
||||
|
||||
util::print_pretty_json(&json);
|
||||
} else {
|
||||
success!("Plaintext: {}", plaintext);
|
||||
success!("Plaintext: {}", text);
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
|
||||
Reference in New Issue
Block a user