Sha256: 0dbb78e876afa0cdb3e943eb735138aa653dd52b183bd637471ca197bdb41a73

Contents?: true

Size: 498 Bytes

Versions: 19

Compression:

Stored size: 498 Bytes

Contents

# frozen_string_literal: true

require 'openssl'


# Much of this comes from Rodauth.
module QuoVadis
  module Hmacable

    def compute_hmac(data)
      OpenSSL::HMAC.hexdigest 'SHA256', hmac_secret, data
    end

    def timing_safe_eql?(provided, actual)
      provided = provided.to_s
      Rack::Utils.secure_compare(provided.ljust(actual.length), actual) && provided.length == actual.length
    end

    private

    def hmac_secret
      Rails.application.secret_key_base
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
quo_vadis-2.2.4 lib/quo_vadis/hmacable.rb
quo_vadis-2.2.2 lib/quo_vadis/hmacable.rb
quo_vadis-2.2.1 lib/quo_vadis/hmacable.rb
quo_vadis-2.2.0 lib/quo_vadis/hmacable.rb
quo_vadis-2.1.11 lib/quo_vadis/hmacable.rb
quo_vadis-2.1.10 lib/quo_vadis/hmacable.rb
quo_vadis-2.1.9 lib/quo_vadis/hmacable.rb
quo_vadis-2.1.8 lib/quo_vadis/hmacable.rb
quo_vadis-2.1.7 lib/quo_vadis/hmacable.rb
quo_vadis-2.1.6 lib/quo_vadis/hmacable.rb
quo_vadis-2.1.5 lib/quo_vadis/hmacable.rb
quo_vadis-2.1.4 lib/quo_vadis/hmacable.rb
quo_vadis-2.1.3 lib/quo_vadis/hmacable.rb
quo_vadis-2.1.2 lib/quo_vadis/hmacable.rb
quo_vadis-2.1.1 lib/quo_vadis/hmacable.rb
quo_vadis-2.1.0 lib/quo_vadis/hmacable.rb
quo_vadis-2.0.2 lib/quo_vadis/hmacable.rb
quo_vadis-2.0.1 lib/quo_vadis/hmacable.rb
quo_vadis-2.0.0 lib/quo_vadis/hmacable.rb