darkirc: Implement --gen-secret

This commit is contained in:
parazyd
2023-07-19 17:32:23 +02:00
parent bcf1f2389a
commit 5b21ae1c4a
3 changed files with 13 additions and 0 deletions

View File

@@ -45,6 +45,8 @@ transport_mixing = false
## ====================
##
## You can create a shared secret with `darkirc --gen-secret`.
## Never share this secret over unencrypted channels or with someone
## who you do not want to be able to read all the channel messages.
## Use it like this example:
#[channel."#foo"]
#secret = "7CkVuFgwTUpJn5Sv67Q3fyEDpa28yrSeL5Hg2GqQ4jfM"

View File

@@ -85,6 +85,13 @@ async fn realmain(settings: Args, executor: Arc<smol::Executor<'_>>) -> Result<(
return Ok(())
}
if settings.gen_secret {
let secret_key = crypto_box::SecretKey::generate(&mut OsRng);
let encoded = bs58::encode(secret_key.to_bytes());
println!("{}", encoded.into_string());
return Ok(())
}
////////////////////
// Initialize the base structures
////////////////////

View File

@@ -71,6 +71,10 @@ pub struct Args {
#[structopt(long)]
pub gen_keypair: bool,
/// Generate a new NaCl secret for an encrypted channel and exit
#[structopt(long)]
pub gen_secret: bool,
/// Path to save keypair in
#[structopt(short)]
pub output: Option<String>,