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

@@ -31,22 +31,24 @@ impl Command for CommandImpl {
let json_output = cmdutil::check_json_output(sub_arg_matches);
let text = sub_arg_matches.value_of("plaintext").unwrap().to_string();
let hmac_encrypt_ciphertext = hmac_encrypt(&text, &mut None, sub_arg_matches)?;
let ciphertext = do_encrypt(&text, &mut None, sub_arg_matches)?;
let ciphertext = hmacutil::hmac_encrypt_from_string(&ciphertext)?;
if json_output {
let mut json = BTreeMap::<&'_ str, String>::new();
json.insert("ciphertext", hmac_encrypt_ciphertext);
json.insert("ciphertext", ciphertext);
util::print_pretty_json(&json);
} else {
success!("HMAC encrypt ciphertext: {}", hmac_encrypt_ciphertext);
success!("HMAC encrypt ciphertext: {}", ciphertext);
}
Ok(None)
}
}
pub fn hmac_encrypt(text: &str, password_opt: &mut Option<String>, sub_arg_matches: &ArgMatches) -> XResult<String> {
pub fn do_encrypt(text: &str, password_opt: &mut Option<String>, sub_arg_matches: &ArgMatches) -> XResult<String> {
let with_hmac_encrypt = sub_arg_matches.is_present("with-hmac-encrypt");
let with_pbe_encrypt = sub_arg_matches.is_present("with-pbe-encrypt");
let text = if with_pbe_encrypt {
let double_pin_check = sub_arg_matches.is_present("double-pin-check");
@@ -56,5 +58,9 @@ pub fn hmac_encrypt(text: &str, password_opt: &mut Option<String>, sub_arg_match
} else {
text.to_string()
};
Ok(hmacutil::hmac_encrypt_from_string(&text)?)
if with_hmac_encrypt {
Ok(hmacutil::hmac_encrypt_from_string(&text)?)
} else {
Ok(text)
}
}