Making HMAC Hashes in Ruby
May 5th, 2007
I was trying to make a quick little Ruby script for Authorize.net SIM for one of my clients and became really annoyed trying to find a flipping document, tutorial or README on HMAC for Ruby. I eventually found something rather unrelated to what I am doing but had the little piece of code that saved my life that day.
OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('md5'), key, data)
How handy, HMAC lives right inside Ruby's OpenSSL libraries--just fill in the key and data variables. Before I found this I tried installing HMAC Libraries directly but with no luck obviously. It still amazes me how little documentation is out there for HMAC with Ruby.
November 11th, 2007 at 09:24 AM I agree entirely. *sigh* I keep running into little bits of Ruby where the whole Ruby world would be improved by a little library-creation and documentation effort.