Sha256: f97c60b99e2294cfe2c6b77b2a590f05d5c290e83ebd48b83cd8a88ed5b24b05

Contents?: true

Size: 587 Bytes

Versions: 6

Compression:

Stored size: 587 Bytes

Contents

require 'bcrypt'

module Goma
  module Encryptors
    class Bcrypt
      class << self
        def encrypt(*tokens)
          ::BCrypt::Password.create(tokens.flatten.join, cost: Goma.config.stretches)
        end

        def valid_password?(encrypted_password, password)
          return false if encrypted_password.blank?

          bcrypt = ::BCrypt::Password.new(encrypted_password)
          password = ::BCrypt::Engine.hash_secret("#{password}#{Goma.config.pepper}", bcrypt.salt)
          Goma.secure_compare(password, encrypted_password)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
goma-0.0.1.rc3 lib/goma/encryptors/bcrypt.rb
goma-0.0.1.rc2 lib/goma/encryptors/bcrypt.rb
goma-0.0.1.rc1 lib/goma/encryptors/bcrypt.rb
goma-0.0.1.gamma lib/goma/encryptors/bcrypt.rb
goma-0.0.1.beta lib/goma/encryptors/bcrypt.rb
goma-0.0.1.alpha lib/goma/encryptors/bcrypt.rb