Sha256: 5704f105912897275b640562432a7449c50b505ee76b1931813d102a8ccaea3e
Contents?: true
Size: 804 Bytes
Versions: 1
Compression:
Stored size: 804 Bytes
Contents
module Gibberish # Easy to use HMAC, defaults to SHA1 # # ## Example # # Gibberish::HMAC('key', 'data') #=> 104152c5bfdca07bc633eebd46199f0255c9f49d # Gibberish::HMAC('key', 'data', :digest => :sha256) # #=> 5031fe3d989c6d1537a013fa6e739da23463fdaec3b70137d828e36ace221bd0 # class HMAC DIGEST = { :sha1 => OpenSSL::Digest::Digest.new('sha1'), :sha256 => OpenSSL::Digest::Digest.new('sha256') } def self.digest(key, data, opts={}) digest_type = opts[:digest] || :sha1 if opts[:binary] OpenSSL::HMAC.digest(DIGEST[digest_type], key, data) else OpenSSL::HMAC.hexdigest(DIGEST[digest_type], key, data) end end end def self.HMAC(key, data, opts={}) Gibberish::HMAC.digest(key, data, opts) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gibberish-1.0.0 | lib/gibberish/hmac.rb |