How to create an MD5 hash with an HMAC module in Ruby?

Using Google + Bing did not answer the question, which should be simple:

How should you use the HMAC module in Ruby to create HMAC with MD5 (which uses a secret)?

HMAC documents seem terribly worse.

Thanks!

+7
ruby ruby-on-rails md5 hmac
source share
5 answers

The following stone must be installed: 'ruby-hmac'

$ irb >> require 'hmac-md5' => true >> HMAC::MD5.new("abc").digest => "\324\035\214\331\217\000\262\004\351\200\t\230\354\370B~" >> HMAC::MD5.new("abc").hexdigest => "d41d8cd98f00b204e9800998ecf8427e" >> 
+7
source share

This should be the easiest way:

 OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('md5'), secret_key, your_data) 
+14
source share

This is what I did:

 HMAC::MD5.new(shared_key).update(data).hexdigest 
+4
source share

Maybe you just need HMAC :: MD5.new (SECRET) .digest

First, search for the salted hash. It depends on your use, but adding a fixed line helps, making your hashes different from those of other applications. Thus, dictionary attack is more complicated. But it's just that.

+1
source share

http://betterlogic.com/roger/?p=152

not?

Or do I remember how he played with him inside one of our Gems, so maybe you can redesign it?

http://github.com/appoxy/aws/tree/master

Hope this helps.

Chad

-one
source share

All Articles