按hmac方式生成签名
@param  array  $params 待签的参数
@return string
353189
protected function generateHmacSign($params = [])
    {
        static::sortParams($params);  // 排序

        $arr = [];
        foreach ($params as $k => $v) {
            $arr[] = $k . $v;
        }
        
        $str = implode('', $arr);

        return strtoupper(hash_hmac('md5', $str, $this->app->app_secret));
    }
1076018
private function getFullName(array $params): string
    {
        if (isset($params['full_name'])) {
            return $this->get($params, 'full_name', '');
        }

        return trim(sprintf('%s %s', $this->get($params, 'first', ''), $this->get($params, 'last', '')));
    }
111740
protected function implodeParams(array $params)
    {
        $s = '';

        foreach ($params as $header => $value) {
            $s .= trim($header) . ": " . trim($value) . "\r\n";
        }

        return $s;
    }
1173979
protected function generateSign($params)
    {
        ksort($params);

        $stringToBeSigned = $this->clientSecret;

        foreach ($params as $k => $v) {
            if (!is_array($v) && '@' != substr($v, 0, 1)) {
                $stringToBeSigned .= "$k$v";
            }
        }

        $stringToBeSigned .= $this->clientSecret;

        return strtoupper(md5($stringToBeSigned));
    }
412240
private function generateCacheKey($key, $params)
    {
        // If our parameters is an array
        // we need to do some work to it.
        if (is_array($params)) {
            // Sort array and maintain index
            asort($params);

            // Convert array to a query string
            $params = http_build_query($params);
        }

        return $key.'|'.$params;
    }
1038702
protected function makeSign(array $params):string
    {
        unset($params['sign']);
        kSortRecursive($params);
        $paramsString = $this->paramsToString($params);

        return md5($paramsString . md5($this->key . $this->secret));
    }
305396
protected function prepareParams(array $params)
	{
		$prepared = [];
		
		foreach($params as $k => $v)
		{
			if(is_array($v))
			{
				foreach(array_values($v) as $i => $val)
				{
					$prepared[sprintf('%s%u', $k, $i)] = $val;
				}
			}
			else
			{
				$prepared[(string)$k] = $v;
			}
		}
		
		return $prepared;
	}
5551
private function decorateParamsForMethodCall(array $params) : string
    {
        $params_out = [];
        foreach($params as $param) {
            $params_out[] = $this->decorateValue($param);
        }
        return implode(',',$params_out);
    }
316319
public function getAuthorizationCode(array $params)
	{
		if (isset($params['transaction_state'])) {
			$params['transaction_state'] = json_encode($params['transaction_state']);
		}

		return $this->post('access/getAuthorizationCode', $params);
	}
43855
public function verifyRequest(array $params)
    {
        if ($this->apiSecret === null) {
            // Secret is required
            throw new Exception('API secret is missing');
        }

        // Ensure shop, timestamp, and HMAC are in the params
        if (array_key_exists('shop', $params)
            && array_key_exists('timestamp', $params)
            && array_key_exists('hmac', $params)
        ) {
            // Grab the HMAC, remove it from the params, then sort the params for hashing
            $hmac = $params['hmac'];
            unset($params['hmac']);
            ksort($params);

            // Encode and hash the params (without HMAC), add the API secret, and compare to the HMAC from params
            return $hmac === hash_hmac('sha256', urldecode(http_build_query($params)), $this->apiSecret);
        }

        // Not valid
        return false;
    }
160066
protected function serializeParams(array $params)
    {
        $serialized = array();
        foreach ($params as $param) {
            $serialized[] = $this->serializer->serialize($param);
        }

        return $serialized;
    }
1027899
protected function _params2string($params)
    {
        if (!count($params)) {
            return '';
        }
        $paramsPart = array();
        foreach ($params as $name => $value) {
            if (!$value && ('0' !== $value)) {
                continue;
            }
            $paramsPart[] = str_replace(array('{name}', '{value}'), array($name, urlencode($value)), $this->paramsPairStructure);
        }
        if (!count($paramsPart)) {
            return '';
        }
        return '/' . implode($this->paramsSeparator, $paramsPart);
    }
819397
private static function formatParameters(array $params)
    {
        return '[' . implode(', ', array_map(static function ($param) {
            if (is_resource($param)) {
                return (string) $param;
            }

            $json = @json_encode($param);

            if (! is_string($json) || $json === 'null' && is_string($param)) {
                // JSON encoding failed, this is not a UTF-8 string.
                return sprintf('"%s"', preg_replace('/.{2}/', '\\x$0', bin2hex($param)));
            }

            return $json;
        }, $params)) . ']';
    }
457361
private function formatParams(array $params) {
        foreach ($params as $key => $value) {
            if (is_array($value)) {
                $params[$key] = implode(',', $value);
            } else if (is_bool($value)) {
                $params[$key] = $value ? 1 : 0;
            }
        }
        return $params;
    }
168867
public static function buildQueryStr($params) {
        $arrTmp = array();
        foreach ($params as $k => $v){
            //参数为空不参与签名
            if(isset($v) && $v != ''){
                array_push($arrTmp, "$k=$v");
            }
        }
        return implode('&', $arrTmp);
    }
96685
public function getSignatureHash($signature, array $params = [])
    {
        if (empty($params)) {
            return hash($this->hashAlgo, $signature);
        } else {
            return hash($this->hashAlgo, $this->getSignatureValue($signature, $params));
        }
    }
564072
private function _constructPdoDsn(array $params)
    {
        $dsn = 'mysql:';
        if (isset($params['host']) && $params['host'] != '') {
            $dsn .= 'host=' . $params['host'] . ';';
        }
        if (isset($params['port'])) {
            $dsn .= 'port=' . $params['port'] . ';';
        }
        if (isset($params['database'])) {
            $dsn .= 'dbname=' . $params['database'] . ';';
        }
        if (isset($params['unix_socket'])) {
            $dsn .= 'unix_socket=' . $params['unix_socket'] . ';';
        }
        if (isset($params['character_set'])) {
            // Let's use the new character_set parameter
            $charset = $params['character_set'];
        } elseif (isset($params['charset'])) {
            // Let's use the old charset parameter
            $charset = $params['charset'];
        } else {
            $charset = null;
        }
        if ($charset !== null) {
            $dsn .= 'charset=' . $charset . ';';
        }

        return $dsn;
    }