Skip to main content

RandomPasswordEntropy

Struct RandomPasswordEntropy 

Source
pub struct RandomPasswordEntropy { /* private fields */ }
Expand description

Entropy bits estimate defined in NIST SP-800-63-1 Randomly Selected Passwords. see http://csrc.nist.gov/publications/nistpubs/800-63-1/SP-800-63-1.pdf A1. “Randomly Selected Passwords”

§Example

   use passay_rs::entropy::RandomPasswordEntropy;
   use passay_rs::rule::Rule;
   use passay_rs::rule::character_characteristics::CharacterCharacteristics;
   use passay_rs::rule::character::CharacterRule;
   use passay_rs::rule::character_data::EnglishCharacterData;
   use passay_rs::rule::allowed_character::AllowedCharacter;
   use passay_rs::rule::PasswordData;
   use passay_rs::entropy::Entropy;

   let allowed_rules = AllowedCharacter::from_chars("abcdefghijklmnopqrstuvwxyzL");
   let ch_rules = vec![
       CharacterRule::new(Box::new(EnglishCharacterData::UpperCase), 1).unwrap(),
       CharacterRule::new(Box::new(EnglishCharacterData::LowerCase), 1).unwrap(),
   ];
   let char_rule = CharacterCharacteristics::with_rules_and_characteristics(ch_rules, 2).unwrap();

   let rules:Vec<Box<dyn Rule>> = vec![Box::new(allowed_rules), Box::new(char_rule)];
   let entropy = RandomPasswordEntropy::new(rules.as_slice(), &PasswordData::with_password("heLlo".to_string())).unwrap();
   let ent = entropy.estimate();
   assert_eq!(28.50219859070546, ent);

Implementations§

Source§

impl RandomPasswordEntropy

Source

pub fn new( rules: &[Box<dyn Rule>], password_data: &PasswordData, ) -> Result<Self, &'static str>

Trait Implementations§

Source§

impl Entropy for RandomPasswordEntropy

Source§

fn estimate(&self) -> f64

Returns the estimated entropy bits of a password.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V