From e7ffeb1183e799a6ef54ba3329a79e3a6bde64dc Mon Sep 17 00:00:00 2001 From: EETagent Date: Mon, 9 Jan 2023 17:36:49 +0100 Subject: [PATCH] feat: add create admin function to cli --- cli/src/main.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cli/src/main.rs b/cli/src/main.rs index fde048e..0b8b8a5 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -235,6 +235,16 @@ async fn main() -> Result<(), Box> { .required(true), ) ) + .subcommand( + Command::new("admin") + .about("Create admin") + .arg( + arg!( + -p --password "Password" + ) + .required(true) + ), + ) .get_matches(); match clap.subcommand() { @@ -330,6 +340,24 @@ async fn main() -> Result<(), Box> { println!("{}", result); } + Some(("admin", sub_matches)) => { + let input = sub_matches.get_one::("password").unwrap(); + + let (pubkey, priv_key) = crypto::create_identity(); + + let priv_key = crypto::encrypt_password(priv_key, input.to_string()) + .await + .unwrap(); + + let password_hash = crypto::hash_password(input.to_string()) + .await + .unwrap(); + + + println!("{}", pubkey); + println!("{}", priv_key); + println!("{}", password_hash); + } _ => unreachable!("Exhausted list of subcommands and subcommand_required prevents `None`"), }