feat: v1.8.0, simple-encrypt and simple-decrypt

This commit is contained in:
2024-11-17 10:30:39 +08:00
parent 6a07360dc1
commit 8e6e708c73
7 changed files with 180 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
use std::io::Write;
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::{fs, io};
@@ -32,6 +32,13 @@ impl AsRef<[u8]> for SecVec {
}
}
pub fn read_stdin() -> XResult<Vec<u8>> {
let mut buffer = vec![];
let mut stdin = io::stdin();
opt_result!(stdin.read_to_end(&mut buffer), "Read stdin failed: {}");
Ok(buffer)
}
pub fn read_pin(pin: &Option<String>) -> XResult<String> {
let rpin = match pin {
Some(pin) => pin.to_string(),