class SequelAuth::Providers::Bcrypt
Public Class Methods
cost()
click to toggle source
# File lib/sequel_auth/providers/bcrypt.rb, line 8 def cost @cost ||= ::BCrypt::Engine.cost end
cost=(val)
click to toggle source
# File lib/sequel_auth/providers/bcrypt.rb, line 12 def cost=(val) raise ArgumentError,"cost < #{min_cost} not allowed!" if val < min_cost @cost = val end
encrypt(password)
click to toggle source
# File lib/sequel_auth/providers/bcrypt.rb, line 17 def encrypt(password) raise ArgumentError, "password not a valid string" if !password.is_a?(String) || password.strip.empty? ::BCrypt::Password.create(password, cost: cost) end
matches?(hash,password)
click to toggle source
# File lib/sequel_auth/providers/bcrypt.rb, line 22 def matches?(hash,password) ::BCrypt::Password.new(hash)==password rescue ::BCrypt::Errors::InvalidHash false end
Private Class Methods
min_cost()
click to toggle source
# File lib/sequel_auth/providers/bcrypt.rb, line 29 def min_cost ::BCrypt::Engine::MIN_COST end