Skip to content

Commit

Permalink
Use shorter passphrase words, make them less than 32-characters long
Browse files Browse the repository at this point in the history
  • Loading branch information
timvisee committed Mar 12, 2019
1 parent 9a27be2 commit fdf8ae9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/cmd/arg/gen_passphrase.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
use chbs;
use chbs::{
config::BasicConfig,
prelude::*,
word::WordList,
};
use clap::Arg;

use super::{CmdArg, CmdArgFlag};

/// How many words the passphrase should consist of.
const PASSPHRASE_WORDS: usize = 5;

/// The passphrase generation argument.
pub struct ArgGenPassphrase {}

impl ArgGenPassphrase {
/// Generate a cryptographically secure passphrase that is easily
/// rememberable using diceware.
pub fn gen_passphrase() -> String {
chbs::passphrase()
let mut config = BasicConfig::default();
config.words = PASSPHRASE_WORDS;
config.word_provider = WordList::builtin_eff_general_short().sampler();
config.to_scheme().generate()
}
}

Expand Down

0 comments on commit fdf8ae9

Please sign in to comment.