The method signature must be generated by taking the query string, and creating a HMAC-SHA256 signature using your API key as the secret key.

salesforce way of generating signature

String algorithmName = 'RSA';
String key = '';
Blob privateKey = EncodingUtil.base64Decode(key);
Blob input = Blob.valueOf('12345qwerty');
Crypto.sign(algorithmName, input, privateKey);

its not working. I am not able to get the meaning of first line, I have referred this links http://blog.jeffdouglas.com/2010/07/06/using-rsa-sha1-with-salesforce-crypto-class/ enter link description here

what should be proper value of input :: any random value OR some meaningful value


The input for String key should be the PKCS#8 formatted Private key. If you follow the instructions on the blog you linked to, use the string of characters between the outputted -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----.

Short Version of instructions -

  1. Generate a private / public key pair (CA or Self signed is up to you), formatted RSA / SHA1, in .PEM format.
  2. Convert .pem format private key to PKCS#8 format openssl pkcs8 -topk8 -nocrypt -in myPrivateKey.pem -outform PEM
  3. Take terminal output between -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- and use as String key = ''; - Make sure you do not have any line-breaks or carriage returns in the string, as is usually output to the terminal. This will make your key not work as Apex does not support multi-line strings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.