feat: v1.12.10

This commit is contained in:
2025-05-06 23:47:18 +08:00
parent 81f7a6d77e
commit d6ecdb5ed4
13 changed files with 40 additions and 37 deletions

View File

@@ -32,7 +32,11 @@ impl Command for CommandImpl {
let ciphertext = sub_arg_matches.value_of("ciphertext").unwrap();
let auto_pbe = sub_arg_matches.is_present("auto-pbe");
let text = hmac_decrypt(ciphertext, auto_pbe)?;
let text = if pbeutil::is_simple_pbe_encrypted(ciphertext) {
pbeutil::simple_pbe_decrypt_with_prompt_to_string(&ciphertext)?
} else {
hmac_decrypt(ciphertext, auto_pbe)?
};
if json_output {
let mut json = BTreeMap::<&'_ str, String>::new();
@@ -47,9 +51,11 @@ impl Command for CommandImpl {
}
}
pub fn try_hmac_decrypt(ciphertext: &str) -> XResult<String> {
pub fn try_decrypt(ciphertext: &str) -> XResult<String> {
if is_hmac_encrypted(ciphertext) {
hmac_decrypt(ciphertext, true)
} else if pbeutil::is_simple_pbe_encrypted(ciphertext) {
pbeutil::simple_pbe_decrypt_with_prompt_to_string(&ciphertext)
} else {
Ok(ciphertext.to_string())
}
@@ -58,7 +64,7 @@ pub fn try_hmac_decrypt(ciphertext: &str) -> XResult<String> {
pub fn hmac_decrypt(ciphertext: &str, auto_pbe: bool) -> XResult<String> {
let text = hmac_decrypt_to_string(ciphertext)?;
if auto_pbe && pbeutil::is_simple_pbe_encrypted(&text) {
Ok(pbeutil::simple_pbe_decrypt_with_prompt_to_string(&text)?)
pbeutil::simple_pbe_decrypt_with_prompt_to_string(&text)
} else {
Ok(text)
}