module SecurePassword

Public Class Methods

cost() click to toggle source
# File lib/secure_password.rb, line 8
def self.cost
  @cost || BCrypt::Engine.cost
end
cost=(cost) click to toggle source
# File lib/secure_password.rb, line 12
def self.cost=(cost)
  @cost = cost
end

Public Instance Methods

authenticate(unencrypted) click to toggle source
# File lib/secure_password.rb, line 16
def authenticate(unencrypted)
  BCrypt::Password.new(password_digest) == unencrypted
end
password=(unencrypted, cost: SecurePassword.cost) click to toggle source
# File lib/secure_password.rb, line 20
def password=(unencrypted, cost: SecurePassword.cost)
  self.password_digest = BCrypt::Password.create(unencrypted, cost: cost)
end