Class: Zxcvbn::Tester
- Inherits:
-
Object
- Object
- Zxcvbn::Tester
- Defined in:
- lib/zxcvbn/tester.rb
Overview
Allows you to test the strength of multiple passwords without reading and parsing the dictionary data from disk each test. Dictionary data is read once from disk and stored in memory for the life of the Tester object.
Example:
tester = Zxcvbn::Tester.new
tester.add_word_lists("custom" => ["words"])
tester.test("password 1")
tester.test("password 2")
tester.test("password 3")
Instance Method Summary collapse
- #add_word_lists(lists) ⇒ Object
-
#initialize ⇒ Tester
constructor
A new instance of Tester.
- #inspect ⇒ Object
- #test(password, user_inputs = []) ⇒ Object
Constructor Details
#initialize ⇒ Tester
Returns a new instance of Tester.
21 22 23 |
# File 'lib/zxcvbn/tester.rb', line 21 def initialize @data = Data.new end |
Instance Method Details
#add_word_lists(lists) ⇒ Object
29 30 31 |
# File 'lib/zxcvbn/tester.rb', line 29 def add_word_lists(lists) lists.each_pair { |name, words| @data.add_word_list(name, sanitize(words)) } end |
#inspect ⇒ Object
33 34 35 |
# File 'lib/zxcvbn/tester.rb', line 33 def inspect "#<#{self.class}:0x#{__id__.to_s(16)}>" end |
#test(password, user_inputs = []) ⇒ Object
25 26 27 |
# File 'lib/zxcvbn/tester.rb', line 25 def test(password, user_inputs = []) PasswordStrength.new(@data).test(password, sanitize(user_inputs)) end |