Sha256: 67334720411115fbdc6f378fa18c42b526f50717b367d9bb5d9ac9c2041e4eca

Contents?: true

Size: 656 Bytes

Versions: 12

Compression:

Stored size: 656 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, encrypted_password, password)
      return false if encrypted_password.blank?
      bcrypt   = ::BCrypt::Password.new(encrypted_password)
      if klass.pepper.present?
        password = "#{password}#{klass.pepper}"
      end
      password = ::BCrypt::Engine.hash_secret(password, bcrypt.salt)
      Devise.secure_compare(password, encrypted_password)
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
devise-3.5.10 lib/devise/encryptor.rb
devise-3.5.9 lib/devise/encryptor.rb
devise-3.5.8 lib/devise/encryptor.rb
devise-3.5.7 lib/devise/encryptor.rb
devise-4.0.0.rc1 lib/devise/encryptor.rb
devise-3.5.6 lib/devise/encryptor.rb
devise-3.5.5 lib/devise/encryptor.rb
devise-3.5.4 lib/devise/encryptor.rb
devise-3.5.3 lib/devise/encryptor.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/devise-3.5.2/lib/devise/encryptor.rb
devise-3.5.2 lib/devise/encryptor.rb
devise-3.5.1 lib/devise/encryptor.rb