Selkie--Widget--PasswordStrength
NAME
Selkie::Widget::PasswordStrength - Live password-strength meter bound to a TextInput
SYNOPSIS
use Selkie::Widget::TextInput;
use Selkie::Widget::PasswordStrength;
use Selkie::Sizing;
my $pw = Selkie::Widget::TextInput.new(
sizing => Sizing.fixed(1),
placeholder => 'Enter password...',
mask-char => '*',
);
my $meter = Selkie::Widget::PasswordStrength.new(
sizing => Sizing.fixed(1),
input => $pw,
);
$vbox.add($pw);
$vbox.add($meter);DESCRIPTION
Non-focusable widget that subscribes to a TextInput's on-change Supply and renders a five-level strength meter in response.
Scoring is a simple length-plus-character-class heuristic ā long enough for "password1" to look weak and "Correct Horse Battery Staple Example!" to look strong, without pulling in a dictionary or an external dependency. For serious analysis use zxcvbn; this is meant to give users directional feedback while they type.
Levels
weak (score < 20) ā
password-weaktheme slotfair (score < 40) ā
password-fairtheme slotgood (score < 60) ā
password-goodtheme slotstrong (score < 80) ā
password-strongtheme slotvery strong (score >= 80) ā
password-very-strongtheme slot
An empty password uses password-empty. The unfilled part of the bar uses text-dim.
Score formula
score = min(100, length * (1 + 0.5 * (classes-1)) * class-bonus)Where classes is the count of used character classes (lowercase / uppercase / digits / symbols) and class-bonus rewards mixed-class passwords.
ATTRIBUTES
inputā theTextInputto watch. Required.show-labelā include the "weak"/"fair"/etc. label beside the bar. Default True.
method new
method new(
*%args
) returns Selkie::Widget::PasswordStrengthConstructor. Defaults focusable to False (the meter is purely display). Required: :input ā the TextInput to subscribe to. Optional: :show-label (default True) toggles the textual level beside the bar.
method score
method score() returns UIntThe most recent computed score, 0..100.
method label
method label() returns StrThe most recent level label ('', 'weak', ..., 'very strong').
sub score-password
sub score-password(
Str $text
) returns UIntScore a password 0..100 using a simple length + character-class heuristic. Intentionally simple and external-dependency-free. Not a substitute for zxcvbn; good enough to tell users directionally whether their choice is terrible, okay, or solid.