[][src]Struct chbs::word::WordList

pub struct WordList { /* fields omitted */ }

A wordlist.

To load a built-in wordlist, checkout the methods on this struct prefixed with builtin_.
The default wordlist loaded when using default() uses builtin_eff_large().

A loaded fixed wordlist which may be used as word provider for passphrase generation by constructing a sampler using sampler.

It is highly recommended that the worlist contains at least 7776 (65) words to provide enough entropy when uniformly sampling words from it.

Methods

impl WordList[src]

pub fn new(words: Vec<String>) -> Self[src]

Construct a new word list with the given words.

To load a wordlist from a file, use load instead.
To load a built-in wordlist, use the methods on this struct prefixed with builtin_.

Panics

This panics if the given set of words is empty.

pub fn load<P>(path: P) -> Result<Self, WordListError> where
    P: AsRef<Path>, 
[src]

Load a wordlist from a file.

This loads a wordlist from a file at the given path, and constructs a WordList.

  • Words are splitted by any whitespace (including newlines), see char::is_whitespace
  • It assumes any non-whitespace character is part of a word
  • Whitespaces are omitted the final wordlist
  • Emtpy items are omitted
  • The file must not include dice numbers

For wordlists that include dice numbers, the load_diced method may be used instead.
If words are separated in a different manner, manually load each word and use the new constructor instead.

An error is returned if loading the wordlist failed, or if the loaded file didn't contain any words.

File examples

abacus abdomen abdominal abide abiding

or

abacus
abdomen

pub fn load_diced<P>(path: P) -> Result<Self, WordListError> where
    P: AsRef<Path>, 
[src]

Load a diced wordlist from a file.

This loads a diced wordlist from a file at the given path, and constructs a WordList. Many diceware wordlists include dice numbers for each word, these should be omitted when using this crate. This method helps with that.

  • Words are splitted by the newline character (\n).
  • Only the last word on each line is kept, terminated by any whitespace, see char::is_whitespace
  • It assumes any non-whitespace character is part of a word
  • Prefixed words do not have to be dice numbers
  • Lines having a single word with no dice number prefix are included
  • Emtpy lines are omitted

For wordlists that do not include dice numbers, the the regular load method instead.
If words are separated in a different manner, manually load each word and use the new constructor instead.

An error is returned if loading the wordlist failed, or if the loaded file didn't contain any words.

File examples

11111 abacus
11112 abdomen
11113 abdominal

or

#1 (1,1,1,1,2)    abacus
#2 (1,1,1,1,2)    abdomen

pub fn builtin_eff_large() -> Self[src]

Construct wordlist from built-in EFF large.

Use the built-in EFF large list of words, and construct a wordlist from it. This is based on BUILTIN_EFF_LARGE.

pub fn builtin_eff_short() -> Self[src]

Construct wordlist from built-in EFF short.

Use the built-in EFF short list of words, and construct a wordlist from it. This is based on BUILTIN_EFF_SHORT.

Note: this wordlist is considered short, as it only contains 1296 (64) words. The list has an entropy of about 10.3 bits when uniformly sampling words from it.
It is recommended to use a larger wordlist such as builtin_eff_large.

pub fn builtin_eff_general_short() -> Self[src]

Construct wordlist from built-in EFF general short.

Use the built-in EFF general short list of words, and construct a wordlist from it. This is based on BUILTIN_EFF_GENERAL_SHORT.

Note: this wordlist is considered short, as it only contains 1296 (64) words. The list has an entropy of about 10.3 bits when uniformly sampling words from it.
It is recommended to use a larger wordlist such as builtin_eff_large.

Important traits for WordSampler
pub fn sampler(&self) -> WordSampler[src]

Build a sampler for this wordlist.

The word sampler may be used to pull any number of random words from the wordlist for passphrase generation.

Trait Implementations

impl Default for WordList[src]

fn default() -> WordList[src]

Construct a default wordlist.

This uses the built-in EFF large wordlist, which can be constructed with WordList::builtin_eff_large().

impl Clone for WordList[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for WordList[src]

Auto Trait Implementations

impl Send for WordList

impl Sync for WordList

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.