Page 1 of 1

Generate dynamic signature using SHA256

Posted: Thu Nov 07, 2013 10:08 pm
by John6122514

I am creating a RestAPI service and I am running into an issue that I am unable to figure out the in Appery system. Every request must be hashed using HMAC-SHA256 using the secret obtained from the API provider.
I need this to happen dynamically with every request. I know if works if I put the correct signature and token in the header for a particular string. I just need to create an extra step that will change the signature based on the URL string.
Here is how it would be done in Ruby:
require 'base64'
require 'openssl'

secret = "xyz"
request = "GET api.URL.com/endpoint?page=1&per_page=1"

digest = OpenSSL::Digest::Digest.new('sha256')
signature = Base64.encode64(OpenSSL::HMAC.digest(digest, secret, request)).chomp


Generate dynamic signature using SHA256

Posted: Thu Nov 07, 2013 10:22 pm
by Kateryna Grynko

Hi John,

Appery.io doesn't support Ruby, you can use JS. Try: http://www.webtoolkit.info/javascript... or http://www.bichlmeier.info/sha256.html


Generate dynamic signature using SHA256

Posted: Mon Jan 27, 2014 1:08 pm
by Dev

Katya

would you provide some examples with JS?


Generate dynamic signature using SHA256

Posted: Mon Jan 27, 2014 3:55 pm
by Kateryna Grynko

Hi,

Take a look at here please: https://code.google.com/p/crypto-js/#...