Class: Cracklib::Password

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/rubylibcrack.rb

Constant Summary collapse

POTENTIAL_DICT_PATHS =
%w(/usr/share/cracklib/pw_dict /usr/lib/cracklib_dict /usr/lib64/cracklib_dict /var/cache/cracklib/cracklib_dict)
@@dictpath =
""

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(password) ⇒ Password

Returns a new instance of Password.



14
15
16
# File 'lib/rubylibcrack.rb', line 14

def initialize(password)
  @password = password
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'lib/rubylibcrack.rb', line 6

def message
  @message
end

Instance Method Details

#strong?(dictpath = default_dictpath) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rubylibcrack.rb', line 18

def strong?(dictpath = default_dictpath)
  if not valid_dictpath? dictpath
    raise "#{dictpath} is not a valid dictionary path!"
  end
  begin
    @message = check(@password, dictpath)
    return @message.nil?
  rescue
    return true
  end
  return false
end

#weak?(dictpath = default_dictpath) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/rubylibcrack.rb', line 31

def weak?(dictpath = default_dictpath)
  not strong? dictpath
end