Module: Authtools::Password
- Includes:
- Common
- Defined in:
- lib/authtools/password.rb
Class Method Summary collapse
-
.check(password, store) ⇒ Object
Checks the password against the stored password.
-
.generate(password) ⇒ Object
Generates a new salt and rehashes the password.
Instance Method Summary collapse
-
#new(password) ⇒ Object
Alias for generate method.
Methods included from Common
Class Method Details
.check(password, store) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/authtools/password.rb', line 34 def self.check(password, store) hash = self.get_hash(store) salt = self.get_salt(store) if self.hash(password, salt) == hash true else false end end |
.generate(password) ⇒ Object
Generates a new salt and rehashes the password. Returns mixed hash.
Examples
store = Authtools::Password.generate('mysecret')
# => "f7d8f299e342168b7a8b0aeece32e090c4acced13a6bd7f2b26fc
# 88251f550943820d190df00a87d20b7bc00cee332c48f9c4953793837
# 2a6c4fbcbe5d3944ccr1x6DlrfTf6OUrwl6ohoivxN2fAQiblav1sLyd9
# z7PFaQgQH3XxTA0BuMAbFRmMM"
15 16 17 18 19 |
# File 'lib/authtools/password.rb', line 15 def self.generate(password) salt = Authtools::Common.salt hash = self.hash(password, salt) self.store(hash, salt) end |
Instance Method Details
#new(password) ⇒ Object
Alias for generate method
23 24 25 |
# File 'lib/authtools/password.rb', line 23 def new(password) generate(password) end |