Module: SimpleRecord::Password

Defined in:
lib/simple_record/password.rb

Overview

This module contains functions for hashing and storing passwords

Class Method Summary collapse

Class Method Details

.check(password, store) ⇒ Object

Checks the password against the stored password



16
17
18
19
20
21
22
23
24
# File 'lib/simple_record/password.rb', line 16

def Password.check(password, store)
    hash = self.get_hash(store)
    salt = self.get_salt(store)
    if self.hash(password, salt) == hash
        true
    else
        false
    end
end

.create_hash(password) ⇒ Object

Generates a new salt and rehashes the password



9
10
11
12
13
# File 'lib/simple_record/password.rb', line 9

def Password.create_hash(password)
    salt = self.salt
    hash = self.hash(password, salt)
    self.store(hash, salt)
end