Signature quick reference

Cloudinary uses digital signatures both to verify the integrity of a message and to provide authentication for communicating over the Internet using the HTTP protocol. Signatures can help ensure that the message was not tampered with during transit and provide an additional layer of security to ensure that even if the transport channel has been compromised, the contents can still be verified.

Cloudinary's SDKs take care of the signature generation where needed for communication with Cloudinary, so you will only need to manually write the code for generating a signature when NOT using our SDKs or when you want to verify a signature that was sent from Cloudinary.

The following table summarizes Cloudinary's signature usage and the payload signed in each case.

Signature usage Example use case Payload to sign
Generating authentication signatures Authenticating a POST request A string with the parameters used in the POST request to Cloudinary:

  • All parameters added to the method call should be included except: file, resource_type and your api_key.
  • Add the timestamp parameter.
  • Sort all the parameters in alphabetical order.
  • Separate the parameter names from their values with an = and join the parameter/value pairs together with an &.
Verifying notification signatures Verifying a signature in the header of a notification sent from Cloudinary A string containing the entire response body with the X-Cld-Timestamp value appended on the end of the string.
Generating delivery URL signatures The signature component of a signed delivery URL of the format:
/s--SIGNATURE--/
A string including all the components of the delivery URL that will come after the signature component.
Verifying signatures in the JSON response Verifying the signature parameter returned in the response to a method call. A string with the public_id and version parameters, separated from their values with an = and then joined together with an &.

Signature generation

Generate the signature by appending your API secret to the end of the payload to sign described above, and then creating a hexadecimal message digest (hash value) of the string using the SHA-1 function.

For example:

Ruby:
signature = Digest::SHA1.digest(payload_to_sign + api_secret)
PHP:
signature = sha1($payload_to_sign . $api_secret)
Python:
signature = hashlib.sha1(payload_to_sign + api_secret).hexdigest()
Java:
string signature = DigestUtils.sha1Hex(payload_to_sign + api_secret)