Sha256: 13c2d703040ff223a0298619b103012adebf7fef5c1b749dff3683acb6b3e33d
Contents?: true
Size: 535 Bytes
Versions: 52
Compression:
Stored size: 535 Bytes
Contents
class DiscoApp::CarrierRequestService # Return true iff the provided hmac_to_verify matches that calculated from the # given data and secret. def self.is_valid_hmac?(body, secret, hmac_to_verify) ActiveSupport::SecurityUtils.secure_compare(self.calculated_hmac(body, secret), hmac_to_verify.to_s) end # Calculate the HMAC for the given data and secret. def self.calculated_hmac(body, secret) digest = OpenSSL::Digest.new('sha256') Base64.encode64(OpenSSL::HMAC.digest(digest, secret, body)).strip end end
Version data entries
52 entries across 52 versions & 1 rubygems