For a deeper look into our World Check One API, look into:

Overview |  Quickstart |  Documentation |  Downloads

question

Upvotes
Accepted
21 1 1 5

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?

world-checkworld-check-oneencryptionruby
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
4.2k 8 5 6
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
21 1 1 5

I'm getting this

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

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@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!

@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.

Upvotes
21 1 1 5

I'v got it right here

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

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.