🔗 sign Algorithm
General steps for sign generation:
-
Assume that all data sent or received is a set M, and the parameters that need to be signed in the set M are sorted from small to large according to the ASCII code of the parameter name (lexicographic order), using the format of URL key-value pairs (i.e. key1=value1 &key2=value2… ) are spliced into a string stringA.
-
Splice
&secret=key
at the end of stringA to get the stringSignTemp string, perform an MD5 operation on stringSignTemp, and then convert all characters in the string to uppercase to get the sign value.
Important Rules to Note
-
Parameter name ASCII codes are sorted from small to large (lexicographic order);
-
Parameter names are case-sensitive;
-
The transmitted sign parameter does not participate in the sign, and the generated sign is verified against the sign value;
-
The interface may add fields, and the added extension fields must be supported when verifying signs.
Example(PHP)
For example, the parameters passed are as follows:
Step 1: Remove the parameters that do not need to be signed , follow the key=value format for the parameters that need to be signed , and sort them in ASCII dictionary order as follows:
Step 2: Splice &secret=key to the string in the previous step:
Step 3: Perform the md5 value operation on the string in the previous step:
Step 4: Convert the above md5 value to uppercase:
Last updated