Previous topic

Authentication errors

Next topic

Signing example

Generating signature

The signature should be generated as follows:

  1. sort request parameters by their names
  2. for each parameter, concatenate its key and value as a string
  3. concatenate all such strings for all parameters
  4. append the resulting string with the app secret
  5. the sha256 hash of the resulting string in hexadecimal form should be used as the signature

Sample in Node.js:

javascript

function genSign(params, appSecret) {
    var paramsStr = Object.keys(params).sort().map(function(key) {
        return key+params[key];
    }).join('') + appSecret;
    return crypto.createHash('sha256').update(paramsStr).digest('hex');
}