PHP

function generateSign($params, $secretKey) {
  $timestamp = time();
  $sortedParams = $params;
  ksort($sortedParams);
  $sortedParams['timestamp'] = $timestamp;
  $signStr = http_build_query($sortedParams) . $secretKey;
  return md5($signStr);
}

In this implementation, the generateSign function takes two parameters: the object parameter $params and the secret key $secretKey. The function first generates a timestamp and adds it to the sorted object parameter. It then concatenates the name-value pairs with the secret key and generates the md5 hash of the resulting string. The function returns the md5 hash as the sign.

Last updated