feat: v1.9.9
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1989,7 +1989,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tiny-encrypt"
|
||||
version = "1.9.8"
|
||||
version = "1.9.9"
|
||||
dependencies = [
|
||||
"aes-gcm-stream",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tiny-encrypt"
|
||||
version = "1.9.8"
|
||||
version = "1.9.9"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
description = "A simple and tiny file encrypt tool"
|
||||
|
||||
35
src/util.rs
35
src/util.rs
@@ -40,23 +40,26 @@ pub fn read_stdin() -> XResult<Vec<u8>> {
|
||||
}
|
||||
|
||||
pub fn read_pin(pin: &Option<String>) -> XResult<String> {
|
||||
let rpin = match pin {
|
||||
Some(pin) => pin.to_string(),
|
||||
None => if is_use_default_pin() {
|
||||
"123456".into()
|
||||
if let Some(pin) = pin {
|
||||
if pin != "#INPUT#" {
|
||||
return Ok(pin.to_string());
|
||||
}
|
||||
}
|
||||
if is_use_default_pin() {
|
||||
return Ok("123456".into());
|
||||
}
|
||||
let rpin = {
|
||||
let pin_entry = util_env::get_default_pin_entry().unwrap_or_else(|| "pinentry".to_string());
|
||||
if let Some(mut input) = PassphraseInput::with_binary(pin_entry) {
|
||||
let secret = input
|
||||
.with_description("Please input your PIN.")
|
||||
.with_prompt("PIN:")
|
||||
.interact();
|
||||
opt_result!(secret, "Read PIN from pinentry failed: {}")
|
||||
.expose_secret()
|
||||
.to_string()
|
||||
} else {
|
||||
let pin_entry = util_env::get_default_pin_entry().unwrap_or_else(|| "pinentry".to_string());
|
||||
if let Some(mut input) = PassphraseInput::with_binary(pin_entry) {
|
||||
let secret = input
|
||||
.with_description("Please input your PIN.")
|
||||
.with_prompt("PIN:")
|
||||
.interact();
|
||||
opt_result!(secret, "Read PIN from pinentry failed: {}")
|
||||
.expose_secret()
|
||||
.to_string()
|
||||
} else {
|
||||
opt_result!(rpassword::prompt_password("Please input PIN: "), "Read PIN failed: {}")
|
||||
}
|
||||
opt_result!(rpassword::prompt_password("Please input PIN: "), "Read PIN failed: {}")
|
||||
}
|
||||
};
|
||||
Ok(rpin)
|
||||
|
||||
Reference in New Issue
Block a user