Sha256: db3e47dcceab25e93d887e591288bed34108b8a9e7194bd999461666c3ddcbd8

Contents?: true

Size: 548 Bytes

Versions: 8

Compression:

Stored size: 548 Bytes

Contents

module GoogleSafeBrowsing
  class KeyHelper

    def self.web_safe_base64_decode(str)
      str.tr!('-_', '+/')
      str << '=' while str.length % 4 != 0
      Base64.decode64(str)
    end

    def self.web_safe_base64_encode(str)
      str = Base64.encode64(str).chomp
      str.tr('+/', '-_')
    end

    def self.compute_mac_code(data)
      sha1 = OpenSSL::HMAC.digest('sha1',
                                  GoogleSafeBrowsing.config.client_key,
                                  data)
      web_safe_base64_encode sha1
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
google_safe_browsing-0.6.5 lib/google_safe_browsing/key_helper.rb
google_safe_browsing-0.6.4 lib/google_safe_browsing/key_helper.rb
google_safe_browsing-0.6.3 lib/google_safe_browsing/key_helper.rb
google_safe_browsing-0.6.2 lib/google_safe_browsing/key_helper.rb
google_safe_browsing-0.6.1 lib/google_safe_browsing/key_helper.rb
google_safe_browsing-0.6.0 lib/google_safe_browsing/key_helper.rb
google_safe_browsing-0.5.1 lib/google_safe_browsing/key_helper.rb
google_safe_browsing-0.5.0 lib/google_safe_browsing/key_helper.rb