Class: CrackLib::Fascist

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

Overview

Checks a given password and wraps the result. The password is checked when an instance is created (e.g. Fascist.new('my_bad_password')). You can check the result with Fascist#ok?. If the password is weak, the reason given is available in reason.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pw, dict_path = CrackLib.default_dict) ⇒ Fascist

Checks the password pw using the cracklib dictionary at dict_path.



48
49
50
# File 'lib/cracklib.rb', line 48

def initialize(pw, dict_path = CrackLib.default_dict)
  @reason = CrackLib.FascistCheck(pw, dict_path)
end

Instance Attribute Details

#reasonObject (readonly)

The reason why the checked password is weak.



45
46
47
# File 'lib/cracklib.rb', line 45

def reason
  @reason
end

Instance Method Details

#ok?Boolean

Returns false if the checked password was found to be weak, true otherwise (but that doesn’t necessarily mean it’s a strong password).

Returns:

  • (Boolean)


54
55
56
# File 'lib/cracklib.rb', line 54

def ok?
  @reason.nil?
end