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§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RandomPasswordEntropy
impl RefUnwindSafe for RandomPasswordEntropy
impl Send for RandomPasswordEntropy
impl Sync for RandomPasswordEntropy
impl Unpin for RandomPasswordEntropy
impl UnsafeUnpin for RandomPasswordEntropy
impl UnwindSafe for RandomPasswordEntropy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more