some much-needed code cleanup
This commit is contained in:
parent
03337ba52e
commit
6db0a632e5
23
src/main.rs
23
src/main.rs
@ -14,8 +14,11 @@
|
|||||||
If not, see <https://www.gnu.org/licenses/>.
|
If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use age::{self, secrecy::ExposeSecret, Identity, Recipient};
|
use age::{self, secrecy::ExposeSecret};
|
||||||
use chrono::{prelude::{DateTime, Local}, SecondsFormat};
|
use chrono::{
|
||||||
|
prelude::{DateTime, Local},
|
||||||
|
SecondsFormat,
|
||||||
|
};
|
||||||
use glob_match::glob_match;
|
use glob_match::glob_match;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use std::{env, process};
|
use std::{env, process};
|
||||||
@ -33,16 +36,6 @@ fn try_pattern(pattern: String, key_pub: String) -> bool {
|
|||||||
glob_match(&pattern, &key_pub.to_string())
|
glob_match(&pattern, &key_pub.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_generate(pattern: String) -> Option<(String, String)> {
|
|
||||||
let key_priv = age::x25519::Identity::generate();
|
|
||||||
let key_pub = key_priv.to_public();
|
|
||||||
|
|
||||||
glob_match(&pattern, &key_pub.to_string()).then_some((
|
|
||||||
key_priv.to_string().expose_secret().to_string(),
|
|
||||||
key_pub.to_string(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = env::args();
|
let args = env::args();
|
||||||
let pattern = if args.len() < 2 {
|
let pattern = if args.len() < 2 {
|
||||||
@ -81,7 +74,7 @@ fn main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let (key_priv, key_pub) = pairs.first().unwrap();
|
let (key_priv, key_pub) = pairs.first().unwrap();
|
||||||
let timestamp: DateTime<Local> = std::time::SystemTime::now().into();
|
let timestamp = Into::<DateTime<Local>>::into(std::time::SystemTime::now())
|
||||||
let timestamp = timestamp.to_rfc3339_opts(SecondsFormat::Secs, false);
|
.to_rfc3339_opts(SecondsFormat::Secs, false);
|
||||||
println!("# created: {}\n# public key: {key_pub}\n{key_priv}", timestamp);
|
println!("# created: {timestamp}\n# public key: {key_pub}\n{key_priv}");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user