Sha256: 8e42a8c1a750792fadce7a20c6eb5f09abeac5a9e87ad795a01b79893a7b9207

Contents?: true

Size: 644 Bytes

Versions: 12

Compression:

Stored size: 644 Bytes

Contents

require 'bcrypt'

module Devise
  module Encryptor
    def self.digest(klass, password)
      if klass.pepper.present?
        password = "#{password}#{klass.pepper}"
      end
      ::BCrypt::Password.create(password, cost: klass.stretches).to_s
    end

    def self.compare(klass, hashed_password, password)
      return false if hashed_password.blank?
      bcrypt   = ::BCrypt::Password.new(hashed_password)
      if klass.pepper.present?
        password = "#{password}#{klass.pepper}"
      end
      password = ::BCrypt::Engine.hash_secret(password, bcrypt.salt)
      Devise.secure_compare(password, hashed_password)
    end
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
devise-4.3.0 lib/devise/encryptor.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/devise-4.2.1/lib/devise/encryptor.rb
devise-4.2.1 lib/devise/encryptor.rb
devise-4.2.0 lib/devise/encryptor.rb
devise-4.0.3 lib/devise/encryptor.rb
devise-4.1.1 lib/devise/encryptor.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/devise-4.1.0/lib/devise/encryptor.rb
devise-4.1.0 lib/devise/encryptor.rb
devise-4.0.2 lib/devise/encryptor.rb
devise-4.0.1 lib/devise/encryptor.rb
devise-4.0.0 lib/devise/encryptor.rb
devise-4.0.0.rc2 lib/devise/encryptor.rb