Sha256: cee217580fee71c0833bad03ffdb4defb5b5503f82acc6c042587bd21fb6e488
Contents?: true
Size: 756 Bytes
Versions: 10
Compression:
Stored size: 756 Bytes
Contents
module Authenticate module Crypto # # All crypto providers must implement encrypt(secret) and match?(secret, encrypted) module BCrypt require 'bcrypt' def encrypt(secret) ::BCrypt::Password.create secret, cost: cost end def match?(secret, encrypted) return false unless encrypted.present? ::BCrypt::Password.new(encrypted) == secret end def cost @cost ||= ::BCrypt::Engine::DEFAULT_COST end def cost=(val) if val < ::BCrypt::Engine::MIN_COST msg = "bcrypt cost cannot be set below the engine's min cost (#{::BCrypt::Engine::MIN_COST})" raise ArgumentError.new(msg), msg end @cost = val end end end end
Version data entries
10 entries across 10 versions & 1 rubygems