feat: 0.5.2, add --split-print
This commit is contained in:
18
Cargo.lock
generated
18
Cargo.lock
generated
@@ -183,9 +183,9 @@ checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.21.4"
|
||||
version = "0.21.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2"
|
||||
checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
|
||||
|
||||
[[package]]
|
||||
name = "base64ct"
|
||||
@@ -233,9 +233,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
version = "0.6.4"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad152d03a2c813c80bb94fedbf3a3f02b28f793e39e7c214c8a0bcc196343de7"
|
||||
checksum = "d1a12477b7237a01c11a80a51278165f9ba0edd28fa6db00a65ab230320dc58c"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
@@ -1141,9 +1141,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.4.3"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b"
|
||||
checksum = "b559898e0b4931ed2d3b959ab0c2da4d99cc644c4b0b1a35b4d344027f474023"
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
@@ -1380,9 +1380,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rust_util"
|
||||
version = "0.6.43"
|
||||
version = "0.6.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1934a25d960599cde936954c2b88942c63a7decf585cf12fa6aabcaa7e67644"
|
||||
checksum = "45c3036388284b69995eb2864a943b0de55de76ad5b56fc2d3c60fecd7b9ad82"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"libc",
|
||||
@@ -1729,7 +1729,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tiny-encrypt"
|
||||
version = "0.5.1"
|
||||
version = "0.5.2"
|
||||
dependencies = [
|
||||
"aes-gcm-stream",
|
||||
"base64",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tiny-encrypt"
|
||||
version = "0.5.1"
|
||||
version = "0.5.2"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
description = "A simple and tiny file encrypt tool"
|
||||
|
||||
@@ -5,10 +5,7 @@ use std::time::{Instant, SystemTime};
|
||||
|
||||
use clap::Args;
|
||||
use openpgp_card::crypto_data::Cryptogram;
|
||||
use rust_util::{
|
||||
debugging, failure, iff, information, opt_result, simple_error, success,
|
||||
warning, XResult,
|
||||
};
|
||||
use rust_util::{debugging, failure, iff, information, opt_result, println_ex, simple_error, success, util_msg, warning, XResult};
|
||||
use rust_util::util_time::UnixEpochTime;
|
||||
use x509_parser::prelude::FromDer;
|
||||
use x509_parser::x509::SubjectPublicKeyInfo;
|
||||
@@ -51,6 +48,9 @@ pub struct CmdDecrypt {
|
||||
/// Direct print to the console, file must less than 10K
|
||||
#[arg(long, short = 'P')]
|
||||
pub direct_print: bool,
|
||||
/// Split std out and std err
|
||||
#[arg(long)]
|
||||
pub split_print: bool,
|
||||
/// Digest file
|
||||
#[arg(long, short = 'D')]
|
||||
pub digest_file: bool,
|
||||
@@ -66,6 +66,7 @@ impl Drop for CmdDecrypt {
|
||||
}
|
||||
|
||||
pub fn decrypt(cmd_decrypt: CmdDecrypt) -> XResult<()> {
|
||||
if cmd_decrypt.split_print { util_msg::set_logger_std_out(false); }
|
||||
debugging!("Cmd decrypt: {:?}", cmd_decrypt);
|
||||
let config = TinyEncryptConfig::load(TINY_ENC_CONFIG_FILE).ok();
|
||||
|
||||
@@ -155,7 +156,11 @@ pub fn decrypt_single(config: &Option<TinyEncryptConfig>,
|
||||
)?;
|
||||
match String::from_utf8(output) {
|
||||
Err(_) => warning!("File is not UTF-8 content."),
|
||||
Ok(output) => println!(">>>>> BEGIN CONTENT >>>>>\n{}\n<<<<< END CONTENT <<<<<", &output),
|
||||
Ok(output) => if cmd_decrypt.split_print {
|
||||
print!("{}", &output)
|
||||
} else {
|
||||
println!(">>>>> BEGIN CONTENT >>>>>\n{}\n<<<<< END CONTENT <<<<<", &output)
|
||||
}
|
||||
}
|
||||
return Ok(meta.file_length);
|
||||
}
|
||||
@@ -381,7 +386,7 @@ fn select_envelop<'a>(meta: &'a TinyEncryptMeta, config: &Option<TinyEncryptConf
|
||||
}
|
||||
|
||||
envelops.iter().enumerate().for_each(|(i, envelop)| {
|
||||
println!("#{} {}", i + 1, util_envelop::format_envelop(envelop, config));
|
||||
println_ex!("#{} {}", i + 1, util_envelop::format_envelop(envelop, config));
|
||||
});
|
||||
|
||||
let envelop_number = util::read_number("Please select an envelop:", 1, envelops.len());
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
|
||||
use base64::Engine;
|
||||
use base64::engine::general_purpose;
|
||||
use rand::random;
|
||||
use rust_util::{information, simple_error, util_term, warning, XResult};
|
||||
use rust_util::{information, print_ex, simple_error, util_term, warning, XResult};
|
||||
use zeroize::Zeroize;
|
||||
|
||||
use crate::consts::TINY_ENC_FILE_EXT;
|
||||
@@ -116,7 +116,7 @@ pub fn decode_base64_url_no_pad(input: &str) -> XResult<Vec<u8>> {
|
||||
|
||||
pub fn read_number(hint: &str, from: usize, to: usize) -> usize {
|
||||
loop {
|
||||
print!("{} ({}-{}): ", hint, from, to);
|
||||
print_ex!("{} ({}-{}): ", hint, from, to);
|
||||
io::stdout().flush().ok();
|
||||
let mut buff = String::new();
|
||||
let _ = io::stdin().read_line(&mut buff).expect("Read line from stdin");
|
||||
|
||||
Reference in New Issue
Block a user