I need to connect to a REST API that uses SHA256 in its authentication. The pattern is this:
-
generate a hash
-
import secret key
-
generate a SHA256 hash of the secter key and the salt
-
Base-64 encode the hash
-
url-encode the Base-64 encoded hash
-
transmit the result in a header
I know how to do some of this. I can do it all in PHP, but that's not super useful right now. What i want ot know is:
-
How can I generate a SHA256 hash?
-
in php, it would be: $salted_hash = hash_hmac('sha256', $salt, $secretKey, true);
-
How do I urlencode a string?
-
in php it's simply $string = urlencode('string');
If it helps (or it there is an extension or shortcut to use) this is to connect to a Kayako Classic REST API.