feat: v1.12.7

This commit is contained in:
2025-05-05 23:22:16 +08:00
parent 9435b287c8
commit 67568f8f15
7 changed files with 126 additions and 10 deletions

View File

@@ -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)