feat: v0.1.3, sign supports --message-type

This commit is contained in:
2025-07-19 13:51:48 +08:00
parent 927350c4b1
commit 0ffd9c6c28
2 changed files with 15 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "external-command-rs"
version = "0.1.2"
version = "0.1.3"
edition = "2024"
authors = ["Hatter Jiang"]
repository = "https://git.hatter.ink/hatter/external-command-rs"

View File

@@ -102,6 +102,16 @@ pub fn external_sign(
parameter: &str,
alg: &str,
content: &[u8],
) -> XResult<Vec<u8>> {
external_sign_digested(external_command, parameter, alg, content, "")
}
pub fn external_sign_digested(
external_command: &str,
parameter: &str,
alg: &str,
content: &[u8],
digest_type: &str,
) -> XResult<Vec<u8>> {
let mut cmd = Command::new(external_command);
cmd.arg("external_sign");
@@ -111,6 +121,10 @@ pub fn external_sign(
cmd.arg(alg);
cmd.arg("--message-base64");
cmd.arg(STANDARD.encode(content));
if !digest_type.is_empty() && digest_type != "raw" {
cmd.arg("--message-type");
cmd.arg(digest_type);
}
let cmd_stdout = run_command_stdout(cmd)?;
parse_sign_result(&cmd_stdout)