Signature
Signature is a string in hexadecimal format, formed by one-way encoding. This string cannot be decoded or generated independently without knowing all the necessary components. The signature is based on the potential importance of each request parameter.
The SHA-1 hash algorithm is used to generate the signature.
Signature generation algorithm
A signature line is generated:
all query parameters are sorted alphabetically by parameter names;
sorted non-empty parameters are sequentially concatenated into one string (concatenation) using a separator character between them;
The “salt” of the site (salt) is added to the end of the created line through a separator character.
The SHA-1 hash is taken from the received string.
Example code for generating signature
Rules for forming a signature
The encoding of the signed string is UTF-8;
Query parameter names are presented in lowercase. The string may include Latin letters from a to z, numbers from 0 to 9, and the underscore “_”;
The semicolon “;” is used as a separator character between parameters.
Each parameter is appended as a substring ”param_name:param_value”, where param name is the name of the parameter, param_value is the value of the parameter, colon is the internal separator;
If the parameter value is an array, then its elements are also sorted in ascending order of their keys and sequentially connected by a delimiter character. In this case, array elements (nested arrays) are skipped and the delimiter character is not added;
To avoid double signing, the “signature” parameter is always excluded from the signature.
Last updated