@param string $signature
@param array  $params

@return string
555882
public function getSignatureValue($signature, array $params)
    {
        foreach ($params as $ph => $param) {
            $signature = str_replace(
                ['{:' . $ph . '}', '{' . $ph . '}'],
                [$param ? ':' . $param : '', $param],
                $signature
            );
        }
        return $signature;
    }
376944
public function singleton($params = [])
    {
        static $instances = [];

        $signature = serialize($params);
        if (!isset($instances[$signature])) {
            $instances[$signature] = idna_convert::getInstance($params);
        }

        return $instances[$signature];
    }
358221
protected String doSign(final Map<String, String> params) {
        StringBuilder signing = new StringBuilder();

        for (Map.Entry<String, String> entry : params.entrySet()) {
            if (!Strings.isNullOrEmpty(entry.getValue())){
                signing.append(entry.getKey()).append('=').append(entry.getValue()).append("&");
            }
        }

        // append key
        signing.append("key=").append(wepay.getAppKey());

        // md5
        return MD5.generate(signing.toString(), false).toUpperCase();
    }
24984
public function buildSignature($signature_method, $consumer, $token)
    {
        $signature = $signature_method->buildSignature($this, $consumer, $token);
        
        return $signature;
    }
651095
public static function parseSignature($signature) {
        $exploded = explode('-', $signature);
        $name = current($exploded);
        $version = '';
        $part = next($exploded);
        while ($part !== false) {
            $dotPos = strpos($part, '.');
            if ($dotPos > 0 && is_numeric(substr($part, 0, $dotPos))) {
                $version = $part;
                while (($part = next($exploded)) !== false) {
                    $version .= '-' . $part;
                }
                break;
            } else {
                $name .= '-' . $part;
                $part = next($exploded);
            }
        }
        return array(
            $name,
            $version
        );
    }
1130932
public function getReqSign(&$params)
    {
        $params['app_id'] = $this->appId;
        if (empty($params['nonce_str'])) {
            $params['nonce_str'] = md5(uniqid("{$params['app_id']}_"));
        }
        if (empty($params['time_stamp'])) {
            $params['time_stamp'] = strval(time());
        }
        ksort($params);
        $str = '';
        array_walk($params, function ($item, $key) use (&$str) {
            if ($item !== '') {
                $str .= sprintf('%s=%s&', $key, urlencode($item));
            }
        });

        return strtoupper(md5(sprintf('%s%s=%s', $str, 'app_key', $this->secret)));
    }
970915
public static function key(string $key, array $params = []): string
    {
        $key = md5(serialize($key));
        if (count($params) > 0) {
            $key .= '-' . md5(serialize($params));
        }
        return $key;
    }
237768
private function formatMessage(string $message, array $params): string
    {
        $params = \array_values($params);
        \array_unshift($params, $message);
        
        return \sprintf(...$params);
    }
1316843
public static String transformMethodSignature(String signature) {
        StringBuilder buf = new StringBuilder();

        buf.append('(');

        SignatureParser parser = new SignatureParser(signature);
        for (Iterator<String> i = parser.parameterSignatureIterator(); i.hasNext();) {
            String param = i.next();
            param = transformSignature(param);
            buf.append(param);
        }

        buf.append(')');

        return buf.toString();
    }
76705
protected function getSignature(array $parameters)
    {
        if (! array_key_exists(static::SIGNATURE_FIELD, $parameters) || $parameters[static::SIGNATURE_FIELD] == '') {
            throw new \InvalidArgumentException(
                sprintf('Sign key (%s) not present in parameters.', static::SIGNATURE_FIELD)
            );
        }
        return $parameters[static::SIGNATURE_FIELD];
    }
1004919
private function createSignatureHash(Signature $signature)
    {
        $length = $this->getSignatureLength();

        return pack(
            'H*',
            sprintf(
                '%s%s',
                str_pad($this->adapter->decHex($signature->getR()), $length, '0', STR_PAD_LEFT),
                str_pad($this->adapter->decHex($signature->getS()), $length, '0', STR_PAD_LEFT)
            )
        );
    }
177191
protected function generateSignature($method, $url, array $params)
    {
        $concat = implode('&', array_map(function($name, $value){
            return sprintf('%s=%s', $name, $value);
        }, array_keys($params), $params));

        $concatenatedParams = rawurlencode($concat);

        // normalize url
        $urlParts = parse_url($url);
        $scheme   = strtolower($urlParts['scheme']);
        $host     = strtolower($urlParts['host']);
        $port     = isset($urlParts['port']) ? intval($urlParts['port']) : 0;
        $retval   = strtolower($scheme) . '://' . strtolower($host);

        if (!empty($port) && (($scheme === 'http' && $port != 80) || ($scheme === 'https' && $port != 443))) {
            $retval .= ":{$port}";
        }

        $retval .= $urlParts['path'];

        if (!empty($urlParts['query'])) {
            $retval .= "?{$urlParts['query']}";
        }

        $normalizedUrl = rawurlencode($retval);
        $signatureBaseString = "{$method}&{$normalizedUrl}&{$concatenatedParams}";
        # sign the signature string
        $key = rawurlencode($this->consumerSecret) . '&' . rawurlencode($this->oauthSecret);

        return base64_encode(hash_hmac('sha1', $signatureBaseString, $key, true));
    }
308006
private static function getCacheKeyForCall(array $params)
    {
        static $domainLevel = null;

        $params += $_GET;
        $keyStr = '';
        foreach ($params as $param) {
            $keyStr .= serialize($param);
        }

        $keyStr .= Request::domainPrefix(
            $domainLevel ?? $domainLevel = count(explode('.', Config::application('domain')))
        );

        return md5($keyStr);
    }
122859
public static function getSignatureString($params, $secret) {
        $values = array();
        self::extractParamValues($params, $values);
        sort($values, SORT_STRING);
        $string = $secret . implode('', $values);
        return $string;
    }
112185
protected function sign(array $parameters)
    {
        //turn into string and add the secret key to the end
        $signatureString = '';

        foreach ($parameters as $key => $value) {
            $signatureString .= $key . '=' . $value;
        }

        $signatureString .= $this->secret;

        return sha1($signatureString);
    }
1272973
private function _signHeader($endpoint, $authMethod, $params)
    {
        if (!is_array($params)) {
            $params = array();
        }
        if ($authMethod) {
            list($key, $value) = explode('=', substr($authMethod, 1), 2);
            $params[$key] = $value;
        }
        $baseString = '/' . $endpoint;
        ksort($params);
        foreach ($params as $key => $value) {
            $baseString .= '|' . $key . '=' . $value;
        }
        $signature = hash_hmac('sha256', $baseString, $this->_apisecret, false);

        return $signature;
    }
583265
protected function extractArgumentsOptions($signature)
    {
        preg_match_all('/{(.*?)}/', $signature, $argumentsOption);

        return array_map(function ($item) {
            return trim($item, '{}');
        }, $argumentsOption[1]);
    }