Class: Zxcvbn::PasswordStrength

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

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ PasswordStrength

Returns a new instance of PasswordStrength.



7
8
9
10
# File 'lib/zxcvbn/password_strength.rb', line 7

def initialize(data)
  @omnimatch = Omnimatch.new(data)
  @scorer = Scorer.new(data)
end

Instance Method Details

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



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

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