Basic Steps
- Let M be the set of all sent or received data
- Sort the parameters that require signing in set M by parameter name in ascending ASCII order (dictionary order)
- Use URL key-value pair format (
key1=value1&key2=value2...) to concatenate into stringstringA - Append
&appSecret=secretKeytostringAto getstringSignTempstring - Perform MD5 operation on
stringSignTemp - Convert all characters in the resulting string to uppercase to get the final
signaturevalue
Important Rules
Please note the following rules:
- Parameter names must be sorted in ascending ASCII order (dictionary order)
- Parameter names are case-sensitive
- The transmitted signature parameter does not participate in signing, used only for verification
- Interface may add fields, signature verification must support additional extension fields
Example (PHP)
Assume the parameters are:
appId: 12345
chainType: 1
merchantOrderNo: 123123123123
productNameοΌGoodsStep 1: Parameter Sorting
Remove parameters that do not require signing, and sort the parameters that require signing in key=value format:
$stringA = 'appId=12345&chainType=1&merchantOrderNo=123123123123';Step 2: Append Secret Key
$stringSignTemp = $stringA.'&appSecret=secretKey';Step 3: MD5 Encryption
$signature = md5($stringSignTemp);Step 4: Convert to Uppercase
$signature = strtoupper($signature);