Why encryption to Base64 for generating signature is not working in Ruby?

Hi! In Thomson-Reuters-World-Check-One-API-documentation.v1.5 we can see request example and description for it

"Given the above signing text, if a secret key of “1234” is used, the computed HMAC-SHA256 value would be
224B73FC07571E60E8B8D9BAB8107C656D3171F346B96183C665FD4C5330B85D when printed using hex encoding, or
Iktz/AdXHmDouNm6uBB8ZW0xcfNGuWGDxmX9TFMwuF0= when printed using base64 encoding."

And I can get first value (224B73FC07571E60E8B8D9BAB8107C656D3171F346B96183C665FD4C5330B85D) but when I trying to encode it in base64, (I'm using Ruby)

Base64.encode64('224B73FC07571E60E8B8D9BAB8107C656D3171F346B96183C665FD4C5330B85D')

I cannot get (Iktz/AdXHmDouNm6uBB8ZW0xcfNGuWGDxmX9TFMwuF0=).

What am I doing wrong?

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • I'm getting this

    Base64.encode64('224B73FC07571E60E8B8D9BAB8107C656D3171F346B96183C665FD4C5330B85D')
    => "MjI0QjczRkMwNzU3MUU2MEU4QjhEOUJBQjgxMDdDNjU2RDMxNzFGMzQ2Qjk2\nMTgzQzY2NUZENEM1MzMwQjg1RA==\n"

  • @ruslan.valeev

    Thank you for your response!

    Let me know if the links I posted helped you to understand how can correct Base64 be calculated using Ruby.

  • Thank you a lot! First link contain decision of my question!

  • I'v got it right here

    Base64.encode64("#{OpenSSL::HMAC.digest('sha256', '1234', data_to_sign)}").chomp
    => "Iktz/AdXHmDouNm6uBB8ZW0xcfNGuWGDxmX9TFMwuF0="

  • @ruslan.valeev

    Thank you for the confirmation.

    As you are able to generate the Base64 signature correctly, I am accepting the answer on your behalf.

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.