Genreate a Hash (digest) of the $data using $method

@param  string $data       [description]
@param  string $method     [description]
@return string
166665
public static function generate(string $data, string $method='SHA256'): string
  {
    $hash = '';
    $hash = openssl_digest($data,$method);

    return $hash;
  }
1060511
private String hash(String dataId)
   {
      try
      {
         MessageDigest digest = MessageDigest.getInstance(hashAlgorithm);
         digest.update(dataId.getBytes("UTF-8"));
         return new BigInteger(1, digest.digest()).toString(32);
      }
      catch (NumberFormatException e)
      {
         throw new RuntimeException("Could not generate the hash code of '" + dataId + "' with the algorithm '"
            + hashAlgorithm + "'", e);
      }
      catch (UnsupportedEncodingException e)
      {
         throw new RuntimeException("Could not generate the hash code of '" + dataId + "' with the algorithm '"
            + hashAlgorithm + "'", e);
      }
      catch (NoSuchAlgorithmException e)
      {
         throw new RuntimeException("Could not generate the hash code of '" + dataId + "' with the algorithm '"
            + hashAlgorithm + "'", e);
      }
   }
388830
protected function processRequest($data, $method = self::POST)
    {
        $this->_headers['Content-Type'] = 'application/json';
        try {
            $client = new Client();

            // create a log channel
            $log = new Logger(get_class($this));
            $log->pushHandler(new StreamHandler('service_call.log', Logger::DEBUG));

            $subscriber = new LogSubscriber($log);
            $client->getEmitter()->attach($subscriber);

            $response = $client->$method($this->uri, [
                'auth' => [$this->username, $this->password],
                'headers' => $this->_headers,
                'body' => $data
            ]);

            return json_decode($response->getBody());
        } catch (BadResponseException $e) {
            $this->output->error($e->getRequest());
            if ($e->hasResponse()) {
                $this->output->error($e->getResponse());
            }
        }
    }
1332704
protected function checkData($method, &$data, $checksum)
    {
        $freshChecksum = $this->createChecksum($method, $data);
        if ($freshChecksum != $checksum) {
            throw new DataIntegrityException('Checksum of file '.$this->getUrl()." failed. ($freshChecksum != $checksum)");
        }
    }
874551
public MethodHash computeHash(Method method) {
        final MessageDigest digest = Util.getMD5Digest();

        byte[] code;
        if (method.getCode() == null || method.getCode().getCode() == null) {
            code = new byte[0];
        } else {
            code = method.getCode().getCode();
        }

        BytecodeScanner.Callback callback = (opcode, index) -> digest.update((byte) opcode);

        BytecodeScanner bytecodeScanner = new BytecodeScanner();
        bytecodeScanner.scan(code, callback);

        hash = digest.digest();

        return this;
    }
659617
private function createRequest($method, $resource, array $data = [])
    {
        if (!empty($data)) {
            $data['signature'] = $this->apiSignature;
        }

        return $this->requestFactory->createRequest($method, $resource, [], $this->encode($data));
    }
425286
protected function synchronousExecute($method, $verb, array $data = [])
    {
        $request = new Request($method, $verb, [], $this->serialize($data));

        $response = $this->client->send($request);
        return $response;
    }
952173
public function request($method, $url, $data = null)
    {
        $url = (string)$url;
        $data = array('$data' => $data);

        if (!$this->cache && $this->params['cache']) {
            $client_id = isset($this->params['route']['client'])
                ? $this->params['route']['client']
                : $this->params['client_id'];
            $this->cache = new Cache($client_id, $this->params['cache']);
        }

        try {
            if (!$this->server->connected) {
                if ($this->params['proxy']) {
                    $data = $this->request_proxy_data($data);
                }
                if (!$this->authed) {
                    $data['$client'] = isset($this->params['route']['client'])
                        ? $this->params['route']['client']
                        : $this->params['client_id'];
                    // Perform basic auth by default for secure/non-route based requests
                    if (!isset($this->server->options['clear']) && !isset($this->params['route']['client'])) {
                        $data['$key'] = $this->params['client_key'];
                        if ($this->cache) {
                            $data['$cached'] = $this->cache->get_versions();
                        }
                        if ($this->params['session']) {
                            $data['$session'] = $this->params['session'];
                        }
                    }
                }
                $this->server->connect();
            }
            $result = $this->server->request($method, $url, $data);
        } catch (NetworkException $e) {
            $this->request_rescue($e);
            $result = $this->server->request($method, $url, $data);
        }

        if (isset($result['$auth'])) {
            if (isset($result['$end'])) {
                // Connection ended, retry
                return $this->request($method, $url, $data['$data']);
            } else {
                $result = $this->auth($result['$auth']);
            }
        }

        return $this->response($method, $url, $data, $result);
    }
171574
private function getContext(string $method, $data, array $headers)
    {
        $options = [
            'http' => [
                'header' => $this->join(': ', $headers),
                'method' => $method,
                'content' => $this->getRawData($data),
            ],
        ];

        if (is_array($this->options)) {
            $options = array_merge_recursive($options, $this->options);
        }

        if (!empty($this->cookies)) {
            $options['http']['header'] .= 'Cookie: '.$this->join('=', $this->cookies, '; ');
        }

        $context = stream_context_create($options);

        return $context;
    }
607273
private function callback($theme, $method, $data)
	{
		if ($theme == NULL)
			throw new CHttpException(400, Yii::t('Api.Theme', 'Missing Theme'));

		if ($method == NULL)
			throw new CHttpException(400, Yii::t('Api.Theme', 'Method name is missing'));

		Yii::import('base.themes.' . $theme . '.Theme');
		$theme = new Theme;

		if (method_exists($theme, $method))
			return $theme->$method($data);

		throw new CHttpException(404, Yii::t('Api.Theme', 'Missing callback method.'));
	}
582917
public function send($url, $method = 'GET', $data = [])
    {
        $method = strtolower($method);

        $settings = [
            'headers'  => array_merge([
                'Authorization' => 'Bearer ' . $this->getToken(),
                'Content-Type' => 'application/x-www-form-urlencoded',
            ], $this->getHeaders()),
        ];

        if ($method == 'post') {
            $settings['form_params'] = $data;
        }

        return $this->client
            ->$method($url, $settings);
    }
1286450
protected function getSignature($data, $method = "sha1", $params = [])
    {
        ksort($data);
        if (!function_exists($method)) return false;
        foreach ($data as $k => $v) array_push($params, "{$k}={$v}");
        return $method(join('&', $params));
    }
959495
public function query($interface, $method, $data) {
        $headers = ['rpc_client_name' => $this->config[ 'name' ],
                    'rpc_token' => $this->config[ 'token' ],
                    'rpc_serialize' => $this->config[ 'serialize' ],
                    'rpc_interface' => $interface,
                    'rpc_method' => $method];
        if (IS_SWOOLE && \Co::getuid()) {
            return $this->queryCoroutine($headers, $data);
        } else {
            return $this->queryByRequest($headers, $data);
        }

    }
451860
public static function hash($data) {
        
        if(false === is_string($data) && false === is_numeric($data)) {
            return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or number, "%s" given', __METHOD__, gettype($data)), E_USER_ERROR);
        }

        return hash(self :: HASH_ALGORITHM, $data);
    }
69131
public function request($method, $url, $data = null)
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_HTTPHEADER, array(
            "Content-Type: application/json",
            "Authorization: {$this->public_key},{$this->secret_key}"
        ));
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_URL, $this->api_url . $url);
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);

        if ($data !== null) {
            curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
        }

        $response = curl_exec($curl);

        if (curl_errno($curl)) {
            throw new Error('Curl error: ' . curl_error($curl));
        }
        $info = curl_getinfo($curl);
        if ($info['http_code'] != 200) {
            throw new Error('API responded with wrong status code (' . $info['http_code'] . ')', json_decode($response));
        }

        return $response;
    }
129973
private function transformPaymentInstrumentValue(array $data, $method)
    {
        if ($method == 'card') {
            $instrument = new PaymentInstrumentCard();
        } elseif ($method == 'recurring') {
            $instrument = new PaymentInstrumentRecurring();
        } else {
            throw new Exception\Runtime(sprintf('Method "%s" is not supported', $method));
        }

        $this->map($data, $instrument);

        return $instrument;
    }
441490
protected function action($method, array $data = [], $flush = null)
    {
        $data = $this->data($data);

        $this->clearCache($flush);

        return $this->client->$method($data);
    }