Class: Ronin::Password
Overview
Represents a password that can be stored in the Database.
Instance Method Summary collapse
-
#count ⇒ Integer
The number of credentials which use this password.
-
#digest(algorithm, options = {}) ⇒ String
Hashes the password.
-
#inspect ⇒ String
Inspects the password.
-
#to_s ⇒ String
Converts the password into a String.
Methods included from Model
Instance Method Details
#count ⇒ Integer
The number of credentials which use this password.
116 117 118 |
# File 'lib/ronin/password.rb', line 116 def count self.credentials.count end |
#digest(algorithm, options = {}) ⇒ String
Hashes the password.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/ronin/password.rb', line 84 def digest(algorithm,={}) digest_class = begin Digest.const_get(algorithm.to_s.upcase) rescue LoadError raise(ArgumentError,"Unknown Digest algorithm #{algorithm}") end hash = digest_class.new if [:prepend_salt] hash << [:prepend_salt].to_s end hash << self.clear_text if [:append_salt] hash << [:append_salt].to_s end return hash.hexdigest end |
#inspect ⇒ String
Inspects the password.
144 145 146 |
# File 'lib/ronin/password.rb', line 144 def inspect "#<#{self.class}: #{self.clear_text}>" end |
#to_s ⇒ String
Converts the password into a String.
130 131 132 |
# File 'lib/ronin/password.rb', line 130 def to_s self.clear_text end |