Class: BcryptHmac::Encryptor

Inherits:
Devise::Encryptable::Encryptors::Base
  • Object
show all
Defined in:
lib/bcrypt_hmac.rb

Class Method Summary collapse

Class Method Details

.compare(encrypted_password, password, _stretches = nil, _salt = nil, pepper = nil) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/bcrypt_hmac.rb', line 18

def self.compare(encrypted_password, password, _stretches = nil,
                 _salt = nil, pepper = nil)
  saved_password = BCrypt::Password.new(encrypted_password)
  proposed_password = prepare_for_bcrypt(password, pepper.to_s)

  saved_password == proposed_password
end

.digest(password, stretches = nil, _salt = nil, pepper = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/bcrypt_hmac.rb', line 8

def self.digest(password, stretches = nil, _salt = nil, pepper = nil)
  pre_bcrypt_hash = prepare_for_bcrypt(password, pepper.to_s)

  if stretches
    BCrypt::Password.create(pre_bcrypt_hash, cost: stretches.to_i)
  else
    BCrypt::Password.create(pre_bcrypt_hash)
  end
end