Unable to reproduce AWS signature from example using HMAC SHA256

那年仲夏 提交于 2019-12-02 06:47:21

I can't tell from your post but those are quite possibly exactly the same results, formatted differently.

Your code returns the raw result of the HMAC operation - this is arbitrary binary data so it's not going to print as anything readable. Amazon expect you to provide the hex representation for each byte: your first couple of bytes are "\xae\xee" instead of "aeee"

The easiest way to do this is call hexdigest rather than digest. Note that you should only do this for the final HMAC (when you sign the string to sign with the signing key) not when constructing the signing key

It's possible that your "strange sequence of characters" is in fact the correct output.

OpenSSL::HMAC.digest spits out a value represented in binary, and you are comparing that to a value represented in hex

Check to see what happens when you print out the signature after converting it to hex representation like so:

signature.each_byte.map { |b| "%02x" % b }.join
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!