pub struct LengthAnalyzer;Expand description
LengthAnalyzer is an analyzer that evaluates the strength of a password based on its length.
It assigns a score between 0.0 and 1.0, where:
- Passwords shorter than 8 characters receive a score of 0.0.
- Passwords with 16 or more characters receive a score of 1.0.
- Passwords between 8 and 16 characters receive a score linearly interpolated between 0.0 and 1.0.
§Examples
use password_strength::analyzer;
use password_strength::analyzer::Analyzer;
use password_strength::analyzer::length::LengthAnalyzer;
let analyzer = LengthAnalyzer::default();
assert_eq!(analyzer.analyze("short"), 0.0);
assert_eq!(analyzer.analyze("verylongpassword"), 1.0);
assert_eq!(analyzer.analyze("mediumpass"), 0.25);Trait Implementations§
Source§impl Analyzer for LengthAnalyzer
impl Analyzer for LengthAnalyzer
Source§impl Default for LengthAnalyzer
impl Default for LengthAnalyzer
Source§fn default() -> LengthAnalyzer
fn default() -> LengthAnalyzer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LengthAnalyzer
impl RefUnwindSafe for LengthAnalyzer
impl Send for LengthAnalyzer
impl Sync for LengthAnalyzer
impl Unpin for LengthAnalyzer
impl UnsafeUnpin for LengthAnalyzer
impl UnwindSafe for LengthAnalyzer
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