Class: Zxcvbn::PasswordStrength

Inherits:
Object
  • Object
show all
Defined in:
lib/zxcvbn/password_strength.rb

Instance Method Summary collapse

Constructor Details

#initializePasswordStrength

Returns a new instance of PasswordStrength.



5
6
7
8
# File 'lib/zxcvbn/password_strength.rb', line 5

def initialize
  @omnimatch = Omnimatch.new
  @scorer = Scorer.new
end

Instance Method Details

#test(password, user_inputs = []) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/zxcvbn/password_strength.rb', line 10

def test(password, user_inputs = [])
  password = password || ''
  result = nil
  calc_time = Benchmark.realtime do
    matches = @omnimatch.matches(password, user_inputs)
    result = @scorer.minimum_entropy_match_sequence(password, matches)
  end
  result.calc_time = calc_time
  result
end