Sha256: 98cea0de40295ccc5f69a1124e8850dbfb5cf08a6a67b834b1c8d84d6e410890
Contents?: true
Size: 727 Bytes
Versions: 7
Compression:
Stored size: 727 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 raise ArgumentError.new("bcrypt cost cannot be set below the engine's min cost (#{::BCrypt::Engine::MIN_COST})") end @cost = val end end end end
Version data entries
7 entries across 7 versions & 1 rubygems