Struct chbs::scheme::Scheme[][src]

pub struct Scheme { /* fields omitted */ }

A passphrase generation scheme.

The scheme defines how passphrases should be generated, and can be directly used to so. This scheme holds various components used during generation to modify and combine passphrase parts or words. The scheme may be used as iterator, which will produce an infinite number of passphrases.

It is recommended to use a configuration struct to confige and build a specific Scheme instead of setting one up manually. The chbs crate provides BasicConfig.

A scheme cannot be modified after creation, to ensure passphrase generation and calculating entropy is consistent.

Components

The following components are part of this scheme and the passphrase generation process:

  • The word generator is used once for each passphrase to generate, and provides a set of words to use for that specific phrase. The generator internally samples a known wordlist or generates randomized strings depending on how it is configured.
  • A set of word stylers is used to modify each passphrase word from the generated set, to randomize capitalization, to add special characters and more depending on their configuration. Each styler is applied once to each phrase word in the specified order. If no word styler is available, the words are kept intact.
  • The phrase builder combines the set of now modified passphrase words into a full passphrase, the builder separates the words with a space or anything else depending on it's configuration.
  • A set of phrase stylers is used to modify the full passphrase that is now combined. They may be used for further modifications with full control over the phrase. If no phrase styler is available, the phrase is kept intact.

Examples

The scheme implements Iterator. You may easily generate many passphrases this way:

extern crate chbs;
use chbs::{config::BasicConfig, prelude::*, scheme::Scheme};

let scheme = BasicConfig::default().to_scheme();

scheme.take(8)
    .for_each(|passphrase| println!("{}", passphrase));

Methods

impl Scheme
[src]

Construct a scheme with the given components

When all components for a scheme are collected, a scheme can be constructed using this method.

If you prefer the builder pattern to build a scheme, use SchemeBuilder instead.

Build a configuration based on the given object.

Generate a single passphrase based on this scheme.

Calculate the entropy that passphrases based on this scheme have.

See the documentation on Entropy for details on what entropy is and how it should be calculated.

Trait Implementations

impl Debug for Scheme
[src]

Formats the value using the given formatter. Read more

impl Iterator for Scheme
[src]

The type of the elements being iterated over.

Generate a new passphrase based on this scheme.

This method always returns Some holding a passphrase.

Returns the bounds on the remaining length of the iterator. Read more

Consumes the iterator, counting the number of iterations and returning it. Read more

Consumes the iterator, returning the last element. Read more

Returns the nth element of the iterator. Read more

🔬 This is a nightly-only experimental API. (iterator_step_by)

unstable replacement of Range::step_by

Creates an iterator starting at the same point, but stepping by the given amount at each iteration. Read more

Takes two iterators and creates a new iterator over both in sequence. Read more

'Zips up' two iterators into a single iterator of pairs. Read more

Takes a closure and creates an iterator which calls that closure on each element. Read more

Calls a closure on each element of an iterator. Read more

Creates an iterator which uses a closure to determine if an element should be yielded. Read more

Creates an iterator that both filters and maps. Read more

Creates an iterator which gives the current iteration count as well as the next value. Read more

Creates an iterator which can use peek to look at the next element of the iterator without consuming it. Read more

Creates an iterator that [skip]s elements based on a predicate. Read more

Creates an iterator that yields elements based on a predicate. Read more

Creates an iterator that skips the first n elements. Read more

Creates an iterator that yields its first n elements. Read more

An iterator adaptor similar to [fold] that holds internal state and produces a new iterator. Read more

Creates an iterator that works like map, but flattens nested structure. Read more

🔬 This is a nightly-only experimental API. (iterator_flatten)

Creates an iterator that flattens nested structure. Read more

Creates an iterator which ends after the first [None]. Read more

Do something with each element of an iterator, passing the value on. Read more

Borrows an iterator, rather than consuming it. Read more

Transforms an iterator into a collection. Read more

Consumes an iterator, creating two collections from it. Read more

An iterator method that applies a function as long as it returns successfully, producing a single, final value. Read more

An iterator method that applies a fallible function to each item in the iterator, stopping at the first error and returning that error. Read more

An iterator method that applies a function, producing a single, final value. Read more

Tests if every element of the iterator matches a predicate. Read more

Tests if any element of the iterator matches a predicate. Read more

Searches for an element of an iterator that satisfies a predicate. Read more

🔬 This is a nightly-only experimental API. (iterator_find_map)

unstable new API

Applies function to the elements of iterator and returns the first non-none result. Read more

Searches for an element in an iterator, returning its index. Read more

Searches for an element in an iterator from the right, returning its index. Read more

Returns the maximum element of an iterator. Read more

Returns the minimum element of an iterator. Read more

Returns the element that gives the maximum value from the specified function. Read more

Returns the element that gives the maximum value with respect to the specified comparison function. Read more

Returns the element that gives the minimum value from the specified function. Read more

Returns the element that gives the minimum value with respect to the specified comparison function. Read more

Reverses an iterator's direction. Read more

Converts an iterator of pairs into a pair of containers. Read more

Creates an iterator which [clone]s all of its elements. Read more

Repeats an iterator endlessly. Read more

Sums the elements of an iterator. Read more

Iterates over the entire iterator, multiplying all the elements Read more

Lexicographically compares the elements of this Iterator with those of another. Read more

Lexicographically compares the elements of this Iterator with those of another. Read more

Determines if the elements of this Iterator are equal to those of another. Read more

Determines if the elements of this Iterator are unequal to those of another. Read more

Determines if the elements of this Iterator are lexicographically less than those of another. Read more

Determines if the elements of this Iterator are lexicographically less or equal to those of another. Read more

Determines if the elements of this Iterator are lexicographically greater than those of another. Read more

Determines if the elements of this Iterator are lexicographically greater than or equal to those of another. Read more

Auto Trait Implementations

impl !Send for Scheme

impl !Sync for Scheme