views:

476

answers:

2

Hi all,

Using Google + Bing didn't yield an answer to what should be a simple question:

How are you supposed to use the HMAC module in Ruby to create a HMAC with MD5 (that uses a secret)?

The HMAC docs seem awfully thin.

Thanks!

A: 

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

no?

Or I remember toying with it inside one of our Gems so maybe you can reverse engineer from it?

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

Hope this helps.

Chad

Chad
+2  A: 
$ 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"
>>
DigitalRoss
thanks.to include a secret, is right to do the following?HMAC::MD5.new(SECRET + "abc").digest
Crashalot
Probably you just want HMAC::MD5.new(SECRET).digest
DigitalRoss