#[non_exhaustive]pub struct Password { /* private fields */ }
Expand description
A random password / passphrase generator. The generated password is a string of three words separated by hyphens. Each word is between 6 and 8 characters long. The first character of each word is capitalized.
Implementations§
source§impl Password
impl Password
sourcepub fn entropy(&self) -> f64
pub fn entropy(&self) -> f64
Calculates the entropy of a password based on its length, the number of unique characters used in the password and the number of bits of the hash generated from the password.
Arguments
&self
- An immutable reference to the password.
Returns
f64
- The calculated entropy of the password.
Entropy Ranges
The following ranges can give you an idea of how the entropy is considered:
- Poor: less than 40 bits
- Weak: 40-55 bits
- Reasonable: 56-70 bits
- Strong: 71-80 bits
- Excellent: 81 bits and above
Keep in mind that these values are just rough estimates and the actual entropy of a password depends on the distribution of characters used in the password and the number of unique characters in it, and not just its length.
sourcepub fn hash_length(&self) -> usize
pub fn hash_length(&self) -> usize
Returns the hash length.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the generated passphrase is empty. Returns false if the generated passphrase is not empty.
sourcepub fn new(len: u8, separator: &str, special_chars: Vec<char>) -> Self
pub fn new(len: u8, separator: &str, special_chars: Vec<char>) -> Self
Returns the generated passphrase.
sourcepub fn passphrase(&self) -> &str
pub fn passphrase(&self) -> &str
Returns the generated passphrase.
sourcepub fn password_length(&self) -> usize
pub fn password_length(&self) -> usize
Returns the password length.
sourcepub fn set_passphrase(&mut self, passphrase: &str)
pub fn set_passphrase(&mut self, passphrase: &str)
Sets the generated passphrase.
Trait Implementations§
source§impl PartialEq<Password> for Password
impl PartialEq<Password> for Password
source§impl PartialOrd<Password> for Password
impl PartialOrd<Password> for Password
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more