feat: add ssh-parse-sign

This commit is contained in:
2024-07-03 00:58:30 +08:00
parent 14585af7c6
commit 8a4d030d82
5 changed files with 132 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
use std::fs;
use std::io::Read;
use base64::{DecodeError, Engine};
@@ -32,3 +33,11 @@ pub fn read_stdin() -> XResult<Vec<u8>> {
opt_result!(stdin.read_to_end(&mut buffer), "Read stdin failed: {}");
Ok(buffer)
}
pub fn read_file_or_stdin(file: &str) -> XResult<Vec<u8>> {
if file == "-" {
read_stdin()
} else {
Ok(opt_result!(fs::read(file), "Read file: {} failed: {}", file))
}
}