0

We have 3 parameters that we need to send through the API. One of them is the "apikey" which is a code already provided, the other one is "utcTimeStamp" and the last one is the "signature".

The signature consists of the result of encrypting with a SHA256 algorithm the following parameters:

apikey,privatekey,utcTimeStamp

(privatekey is a code that was also provided to us previously).

Including the comma between each parameter.

How could we generate this signature with these characteristics and return it as a parameter?

More details in the attached image.

Image Desc. Here

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 07 '21 at 18:51
  • The documentation/developers of the API you are using should be able to let you know how to generate the signature. For example the Slack API uses this for verification of signatures: https://api.slack.com/authentication/verifying-requests-from-slack – erran Sep 07 '21 at 18:53

1 Answers1

0

You can do this

let signature = CryptoJS.SHA256("some string").toString();
pm.environment.set("signature", signature);
lucas-nguyen-17
  • 5,516
  • 2
  • 9
  • 20
  • Sorry for my ignorance, then I should copy and paste this code in Pre-Request Script? And it would look more or less like this? let signature = CryptoJS.SHA256("apiKey,utcTimesatamp,other code here").toString(); pm.environment.set("signature", signature); – Júbilo Estudios Sep 03 '21 at 13:48
  • 1
    you could covert `apikey,privatekey,utcTimeStamp` to string first, then pass it to `"some string"`. Please double check how to structure signature with developers. – lucas-nguyen-17 Sep 03 '21 at 13:55
  • Sorry for my ignorance, but how would I do that? – Júbilo Estudios Sep 08 '21 at 19:47