Class: RubyEntropy

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-entropy.rb

Constant Summary collapse

COMMON_PASSPHRASES =

lowercase only

["admin", "administrator", "jesus", "letmein", "master", "open sesame", "opensesame", "password", "passphrase", "sunshine", "trustnoi", "trustnol", "welcome"]
KEY_PATTERNS =
["zxc", "cxz", "bnm", "mnb", "jkl", "lkj", "asd", "dsa", "qwe", "ewq", "iop", "poi"]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(passphrase) ⇒ RubyEntropy

Returns a new instance of RubyEntropy.



9
10
11
# File 'lib/ruby-entropy.rb', line 9

def initialize(passphrase)
  @passphrase = passphrase
end

Instance Attribute Details

#passphraseObject (readonly)

Returns the value of attribute passphrase.



3
4
5
# File 'lib/ruby-entropy.rb', line 3

def passphrase
  @passphrase
end

Class Method Details

.blacklist_passphrase(phrase) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/ruby-entropy.rb', line 17

def self.blacklist_passphrase(phrase)
  if phrase.class != String
    return 'you must enter a string'
  end
  COMMON_PASSPHRASES.push(phrase.downcase)
  return 'success'
end

Instance Method Details

#strengthObject



13
14
15
# File 'lib/ruby-entropy.rb', line 13

def strength
  (31 * bad_passphrase_multiplier * Math.log(entropy / 13.62)).round(2)
end