pub struct PasswordGenerator { /* private fields */ }Expand description
Encapsulates RNG and set of characters. See crate documentation for more.
Implementations§
Source§impl PasswordGenerator
impl PasswordGenerator
Sourcepub fn new(charset: Vec<char>, length: usize) -> Self
pub fn new(charset: Vec<char>, length: usize) -> Self
Creates the PasswordGenerator to yield passwords using either
PasswordGenerator::generate or PasswordGenerator::generate_n
charset will not be deduplicated, so that you could (but should not!)
increase the the probability density of the chars in the generated
passwords.
Sourcepub fn length(self, length: usize) -> Self
pub fn length(self, length: usize) -> Self
Changes the length of the generated passwords, consumes and returns itself.
Sourcepub fn generate(&mut self) -> String
pub fn generate(&mut self) -> String
Generates one password, with characters randomly chosen from the charset.
Sourcepub fn generate_n(&mut self, n: usize) -> Vec<String>
pub fn generate_n(&mut self, n: usize) -> Vec<String>
Generates a vector of passwords with length n, calling
PasswordGenerator::generate internally.
Cannot return an iterator, because that iterator would need to hold
a mutable reference to the generator.
Sourcepub fn combinations(&self) -> f64
pub fn combinations(&self) -> f64
Number of all possible combinations arising from charset and length.