lib/oauth/signature/hmac/sha256.rb in oauth-0.5.14 vs lib/oauth/signature/hmac/sha256.rb in oauth-0.6.0

- old
+ new

@@ -1,17 +1,23 @@ +# frozen_string_literal: true + require "oauth/signature/base" -module OAuth::Signature::HMAC - class SHA256 < OAuth::Signature::Base - implements "hmac-sha256" +module OAuth + module Signature + module HMAC + class SHA256 < OAuth::Signature::Base + implements "hmac-sha256" - def body_hash - Base64.encode64(OpenSSL::Digest::SHA256.digest(request.body || "")).chomp.delete("\n") - end + def body_hash + Base64.encode64(OpenSSL::Digest.digest("SHA256", request.body || "")).chomp.delete("\n") + end - private + private - def digest - OpenSSL::HMAC.digest(OpenSSL::Digest.new("sha256"), secret, signature_base_string) + def digest + OpenSSL::HMAC.digest(OpenSSL::Digest.new("sha256"), secret, signature_base_string) + end + end end end end