feat: fix clippy
This commit is contained in:
@@ -184,10 +184,11 @@ fn encrypt_single(path: &PathBuf, envelops: &[&TinyEncryptConfigEnvelop], cmd_en
|
||||
let _ = util_enc_file::write_tiny_encrypt_meta(&mut file_out, &encrypt_meta, compress_meta)?;
|
||||
|
||||
let compress_desc = iff!(cmd_encrypt.compress, " [with compress]", "");
|
||||
let compress_level = iff!(cmd_encrypt.compress, &cmd_encrypt.compress_level, &None);
|
||||
let start = Instant::now();
|
||||
encrypt_file(
|
||||
&mut file_in, file_metadata.len(), &mut file_out, cryptor,
|
||||
&key.0, &nonce.0, cmd_encrypt.compress, &cmd_encrypt.compress_level,
|
||||
&key.0, &nonce.0, compress_level,
|
||||
)?;
|
||||
drop(file_out);
|
||||
let encrypt_duration = start.elapsed();
|
||||
@@ -220,7 +221,8 @@ fn process_compatible_with_1_0(mut encrypt_meta: TinyEncryptMeta) -> XResult<Tin
|
||||
}
|
||||
|
||||
fn encrypt_file(file_in: &mut File, file_len: u64, file_out: &mut impl Write, cryptor: Cryptor,
|
||||
key: &[u8], nonce: &[u8], compress: bool, compress_level: &Option<u32>) -> XResult<u64> {
|
||||
key: &[u8], nonce: &[u8], compress_level: &Option<u32>) -> XResult<u64> {
|
||||
let compress = compress_level.is_some();
|
||||
let mut total_len = 0_u64;
|
||||
let mut write_len = 0_u64;
|
||||
let mut buffer = [0u8; 1024 * 8];
|
||||
|
||||
@@ -16,7 +16,7 @@ impl Cryptor {
|
||||
match algorithm {
|
||||
"aes256-gcm" | consts::TINY_ENC_AES_GCM => Ok(Cryptor::Aes256Gcm),
|
||||
"chacha20-poly1305" | consts::TINY_ENC_CHACHA20_POLY1305 => Ok(Cryptor::ChaCha20Poly1305),
|
||||
_ => simple_error!("Unknown altorighm: {}",algorithm),
|
||||
_ => simple_error!("Unknown algorithm: {}",algorithm),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
|
||||
use rust_util::{information, simple_error, XResult};
|
||||
use rust_util::{information, print_ex, simple_error, XResult};
|
||||
use yubikey::piv::{RetiredSlotId, SlotId};
|
||||
|
||||
use crate::config::TinyEncryptConfig;
|
||||
@@ -16,7 +16,7 @@ pub fn read_piv_slot(config: &Option<TinyEncryptConfig>, kid: &str, slot: &Optio
|
||||
return Ok(first_arg.to_string());
|
||||
}
|
||||
}
|
||||
print!("Input slot(eg 82, 83 ...): ");
|
||||
print_ex!("Input slot(eg 82, 83 ...): ");
|
||||
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