Sha256: f9699b966977660cdd42e36eee0ce4bce9d5fc1ddecb4d1645c768f7c80694fb
Contents?: true
Size: 575 Bytes
Versions: 6
Compression:
Stored size: 575 Bytes
Contents
require 'openssl' require 'base64' module Stream class Signer @key = nil def initialize(key) @key = key.to_s @sha1 = OpenSSL::Digest.new('sha1') end def urlSafeB64encode(value) value.gsub('+', '-').gsub('/', '_').gsub(/^=+/, '').gsub(/=+$/, '') end def signature(message) key = Digest::SHA1.digest @key.to_s signature = Base64.strict_encode64(OpenSSL::HMAC.digest(@sha1, key, message.to_s)) self.urlSafeB64encode(signature) end end end
Version data entries
6 entries across 6 versions & 1 rubygems