Module: Zxcvbn
- Defined in:
- lib/zxcvbn.rb,
lib/zxcvbn/data.rb,
lib/zxcvbn/math.rb,
lib/zxcvbn/trie.rb,
lib/zxcvbn/clock.rb,
lib/zxcvbn/match.rb,
lib/zxcvbn/score.rb,
lib/zxcvbn/scorer.rb,
lib/zxcvbn/tester.rb,
lib/zxcvbn/guesses.rb,
lib/zxcvbn/version.rb,
lib/zxcvbn/feedback.rb,
lib/zxcvbn/omnimatch.rb,
lib/zxcvbn/crack_time.rb,
lib/zxcvbn/case_helpers.rb,
lib/zxcvbn/match_builder.rb,
lib/zxcvbn/matchers/date.rb,
lib/zxcvbn/matchers/l33t.rb,
lib/zxcvbn/matchers/year.rb,
lib/zxcvbn/feedback_giver.rb,
lib/zxcvbn/tester_builder.rb,
lib/zxcvbn/matchers/digits.rb,
lib/zxcvbn/matchers/repeat.rb,
lib/zxcvbn/matchers/spatial.rb,
lib/zxcvbn/dictionary_ranker.rb,
lib/zxcvbn/matchers/sequences.rb,
lib/zxcvbn/matchers/dictionary.rb,
lib/zxcvbn/matchers/regex_helpers.rb,
sig/zxcvbn.rbs,
sig/zxcvbn/data.rbs,
sig/zxcvbn/math.rbs,
sig/zxcvbn/trie.rbs,
sig/zxcvbn/clock.rbs,
sig/zxcvbn/match.rbs,
sig/zxcvbn/score.rbs,
sig/zxcvbn/scorer.rbs,
sig/zxcvbn/tester.rbs,
sig/zxcvbn/guesses.rbs,
sig/zxcvbn/feedback.rbs,
sig/zxcvbn/omnimatch.rbs,
sig/zxcvbn/crack_time.rbs,
sig/zxcvbn/case_helpers.rbs,
sig/zxcvbn/match_builder.rbs,
sig/zxcvbn/matchers/date.rbs,
sig/zxcvbn/matchers/l33t.rbs,
sig/zxcvbn/matchers/year.rbs,
sig/zxcvbn/feedback_giver.rbs,
sig/zxcvbn/tester_builder.rbs,
sig/zxcvbn/matchers/digits.rbs,
sig/zxcvbn/matchers/repeat.rbs,
sig/zxcvbn/matchers/spatial.rbs,
sig/zxcvbn/dictionary_ranker.rbs,
sig/zxcvbn/matchers/sequences.rbs,
sig/zxcvbn/matchers/dictionary.rbs,
sig/zxcvbn/matchers/regex_helpers.rbs
Overview
Ruby port of zxcvbn.js — realistic password strength estimation.
Analyses a password against dictionary lists, keyboard patterns, dates, sequences, and repeats to produce a Score with guess estimates and human-readable crack-time display strings.
Defined Under Namespace
Modules: CaseHelpers, Clock, CrackTime, Guesses, Matchers, Math Classes: Data, DictionaryRanker, Feedback, FeedbackGiver, Match, MatchBuilder, Omnimatch, PasswordTooLong, Score, Scorer, Tester, TesterBuilder, Trie
Constant Summary collapse
- VERSION =
'2.0.1'
Class Method Summary collapse
-
.test(password, user_inputs = []) ⇒ Score
Returns a Zxcvbn::Score for the given password.
-
.tester_builder ⇒ TesterBuilder
Returns a new TesterBuilder for constructing a Tester with custom word lists and options.
Class Method Details
.test(password, user_inputs = []) ⇒ Score
Returns a Zxcvbn::Score for the given password.
Reuses a shared Tester instance across calls. For custom word lists or options, use tester_builder to build a dedicated Tester.
Raises PasswordTooLong (a subclass of ArgumentError) if the password
exceeds the configured limit (default: 256 characters). Override process-wide
via the ZXCVBN_MAX_PASSWORD_LENGTH environment variable; for per-call limits,
use tester_builder with Zxcvbn::TesterBuilder#max_password_length.
Example:
Zxcvbn.test("password").score #=> 0
37 38 39 |
# File 'lib/zxcvbn.rb', line 37 def test(password, user_inputs = []) default_tester.test(password, user_inputs) end |
.tester_builder ⇒ TesterBuilder
Returns a new TesterBuilder for constructing a Tester with custom word lists and options.
Example:
tester = Zxcvbn
.tester_builder
.add_word_list('company', %w[acme corp])
.max_password_length(75)
.build
53 54 55 |
# File 'lib/zxcvbn.rb', line 53 def tester_builder TesterBuilder.new end |