Module: Kingsman::Encryptor

Defined in:
lib/kingsman/encryptor.rb

Class Method Summary collapse

Class Method Details

.compare(hashed_password, password) ⇒ Object



12
13
14
15
16
17
# File 'lib/kingsman/encryptor.rb', line 12

def self.compare(hashed_password, password)
  return false if hashed_password.blank?
  bcrypt   = ::BCrypt::Password.new(hashed_password)
  password = ::BCrypt::Engine.hash_secret(password, bcrypt.salt)
  Kingsman.secure_compare(password, hashed_password)
end

.digest(password) ⇒ Object



7
8
9
10
# File 'lib/kingsman/encryptor.rb', line 7

def self.digest(password)
  stretches = 12
  ::BCrypt::Password.create(password, cost: stretches).to_s
end