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