I have a small code snippet that I'm trying to get to work in Ruby.
digest = HMAC.digest(Digest.new(SHA1), Base64.decode64(key), HashString) return Base64.encode64(digest.to_s()).chomp()
I tried it as follows:
hashstring = "POST application/octet-stream
Thu, 05 Jun 2008 16:38:19 GMT /rest/objects date:Thu, 05 Jun 2008 16:38:19 GMT groupacl:other=NONE listable-meta:part4/part7/part8=quick meta:part1=buy
id: 6039ac182f194e15b9261d73ce044939/user1 useracl:jane=FULL_CONTROL,juan=WRITE"
key = "AKLuryj6zs8ste4Y3jTGQp71xq0="
def hash(hs, keyh)
digest = HMAC.digest(Digest.new(SHA1), Base64.decode64(keyh), hs)
return Base64.encode64(digest.to_s()).chomp()
end
puts hash hashstring,key
this gives me the error file.rb:1:in `require': no such file to load -- hmac-md5 (LoadError) from file.rb:1
I'm unfamiliar with ruby or how include/require modules work. (or if they are bundled with the language or require seperate downloading. What file/code am I missing to make this function?