'How to pass request data using a public key as a header on Curl

I want to make a Curl request to an api and i am asked to pass a header that contains an authorization format.

Here is the guideline given to me to refer to

[Authentication Our API is based on a single endpoint architecture approach. The specific operations are determined from the requests sent to this endpoint. The KUDA API requires authentication using a combination of your client-Key and a random string which is encrypted using your public key and passed in the header of every request you make.

Public Key: Your public key is used to encrypt requests sent to KUDA. Private Key: The private key is used to decrypt the responses returned by KUDA. Encryption Your API requests must be encrypted and over HTTPS, not plain HTTP.

To encrypt your request data, you use a combination of your client-Key and a randomly generated string delimited by a hyphen.

password = {clientKey}-{randomString}

This clientKey and random string combination must also be encrypted. It must be encrypted with your public key and this forms your “password”.

This “password” is sent in the header and the encrypted request data in the body.

We use a combination of Symmetric and Asymmetric encryption. The "data" should be encrypted using AES256 while the "password" using RSA Encrypted payload using your ClientID - RandomString Encrypted payload using your ClientKey - RandomString ]

Please can someone create a working example of a curl request using the above format?.

Also, do i need to decrypt on getting response data?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source