Class: CrackLib::Fascist
- Inherits:
-
Object
- Object
- CrackLib::Fascist
- 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
-
#reason ⇒ Object
readonly
The reason why the checked password is weak.
Instance Method Summary collapse
-
#initialize(pw, dict_path = CrackLib.default_dict) ⇒ Fascist
constructor
Checks the password
pwusing the cracklib dictionary atdict_path. -
#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).
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
#reason ⇒ Object (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).
54 55 56 |
# File 'lib/cracklib.rb', line 54 def ok? @reason.nil? end |