diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-12-14 11:30:11 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-12-14 11:30:11 +0100 |
commit | 65f4ceae7835a1bed8ff65ecbc4933b4b3553c84 (patch) | |
tree | 5e2559ec5126d9fa3b498b085aa87992e1554ba6 | |
parent | 02626865bf0f076e416db2121b44d7fcad067e29 (diff) | |
download | aerogramme-65f4ceae7835a1bed8ff65ecbc4933b4b3553c84.tar.gz aerogramme-65f4ceae7835a1bed8ff65ecbc4933b4b3553c84.zip |
add a password hash tool
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index c854340..3d87d11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,6 +52,11 @@ enum ToolsCommand { /// Manage crypto roots #[clap(subcommand)] CryptoRoot(CryptoRootCommand), + + PasswordHash { + #[clap(env = "AEROGRAMME_PASSWORD")] + maybe_password: Option<String>, + } } #[derive(Subcommand, Debug)] @@ -190,6 +195,13 @@ async fn main() -> Result<()> { bail!("Your want to run a 'Companion' command but your configuration file has role 'Provider'."); }, (Command::Tools(subcommand), _) => match subcommand { + ToolsCommand::PasswordHash { maybe_password } => { + let password = match maybe_password { + Some(pwd) => pwd.clone(), + None => rpassword::prompt_password("Enter password: ")?, + }; + println!("{}", hash_password(&password)?); + }, ToolsCommand::CryptoRoot(crcommand) => { match crcommand { CryptoRootCommand::New { maybe_password } => { |