本文整理匯總了PHP中rsaDecrypt函數的典型用法代碼示例。如果您正苦於以下問題:PHP rsaDecrypt函數的具體用法?PHP rsaDecrypt怎麽用?PHP rsaDecrypt使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了rsaDecrypt函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parseResponse
/**
* 解析遠程模擬提交後返回的信息
* @param $str_text 要解析的字符串
* @return 解析結果
*/
public function parseResponse($str_text)
{
//以“&”字符切割字符串
$para_split = explode('&', $str_text);
//把切割後的字符串數組變成變量與數值組合的數組
foreach ($para_split as $item) {
//獲得第一個=字符的位置
$nPos = strpos($item, '=');
//獲得字符串長度
$nLen = strlen($item);
//獲得變量名
$key = substr($item, 0, $nPos);
//獲得數值
$value = substr($item, $nPos + 1, $nLen - $nPos - 1);
//放入數組中
$para_text[$key] = $value;
}
if (!empty($para_text['res_data'])) {
//解析加密部分字符串
if ($this->alipay_config['sign_type'] == '0001') {
$para_text['res_data'] = rsaDecrypt($para_text['res_data'], $this->alipay_config['private_key_path']);
}
//token從res_data中解析出來(也就是說res_data中已經包含token的內容)
//$doc = new \DOMDocument('1.0', 'UTF-8');
//$doc->loadXML($para_text['res_data']);
$doc = simplexml_load_string($para_text['res_data']);
$doc = (array) $doc;
$para_text['request_token'] = $doc['request_token'];
}
return $para_text;
}
示例2: decrypt
/**
* 解密
* @param $input_para 要解密數據
* @return 解密後結果
*/
function decrypt($prestr)
{
return rsaDecrypt($prestr, trim($this->alipay_config['private_key_path']));
}
示例3: parseResponse
/**
* 解析遠程模擬提交後返回的信息
* @param $str_text 要解析的字符串
* @return 解析結果
*/
function parseResponse($str_text)
{
//以“&”字符切割字符串
$para_split = explode('&', $str_text);
//把切割後的字符串數組變成變量與數值組合的數組
foreach ($para_split as $item) {
//獲得第一個=字符的位置
$nPos = strpos($item, '=');
//獲得字符串長度
$nLen = strlen($item);
//獲得變量名
$key = substr($item, 0, $nPos);
//獲得數值
$value = substr($item, $nPos + 1, $nLen - $nPos - 1);
//放入數組中
$para_text[$key] = $value;
}
if (!empty($para_text['res_data'])) {
//解析加密部分字符串
if ($this->alipay_config['sign_type'] == '0001') {
$para_text['res_data'] = rsaDecrypt($para_text['res_data'], $this->alipay_config['private_key_path']);
}
//token從res_data中解析出來(也就是說res_data中已經包含token的內容)
$doc = new DOMDocument();
$doc->loadXML($para_text['res_data']);
$para_text['request_token'] = $doc->getElementsByTagName("request_token")->item(0)->nodeValue;
}
return $para_text;
}
示例4: parseResponse
function parseResponse($str_text)
{
$para_split = explode('&', $str_text);
foreach ($para_split as $item) {
$nPos = strpos($item, '=');
$nLen = strlen($item);
$key = substr($item, 0, $nPos);
$value = substr($item, $nPos + 1, $nLen - $nPos - 1);
$para_text[$key] = $value;
}
if (!empty($para_text['res_data'])) {
if ($this->alipay_config['sign_type'] == '0001') {
$para_text['res_data'] = rsaDecrypt($para_text['res_data'], $this->alipay_config['private_key_path']);
}
$doc = new DOMDocument();
$doc->loadXML($para_text['res_data']);
$para_text['request_token'] = $doc->getElementsByTagName("request_token")->item(0)->nodeValue;
}
return $para_text;
}
示例5: prepareMobileTradeData
/**
* 準備移動網頁支付的請求參數
*
* 移動網頁支付接口不同,需要先服務器提交一次請求,拿到返回 token 再返回客戶端發起真實支付請求。
* 該方法隻完成第一次服務端請求,生成參數後需要客戶端另行處理(可調用`buildRequestFormHTML`生成表單提交)。
*
* @param $params <Array>
* $params['out_trade_no'] 訂單唯一編號
* $params['subject'] 商品標題
* $params['total_fee'] 支付總費用
* $params['merchant_url'] 商品鏈接地址
* $params['req_id'] 請求唯一 ID
*
* @return <Array>
*/
function prepareMobileTradeData($params)
{
// 不要用 SimpleXML 來構建 xml 結構,因為有第一行文檔申明支付寶驗證不通過
$xml_str = '<direct_trade_create_req>' . '<notify_url>' . $this->config['notify_url'] . '</notify_url>' . '<call_back_url>' . $this->config['return_url'] . '</call_back_url>' . '<seller_account_name>' . $this->config['seller_email'] . '</seller_account_name>' . '<out_trade_no>' . $params['out_trade_no'] . '</out_trade_no>' . '<subject>' . htmlspecialchars($params['subject'], ENT_XML1, 'UTF-8') . '</subject>' . '<total_fee>' . $params['total_fee'] . '</total_fee>' . '<merchant_url>' . $params['merchant_url'] . '</merchant_url>' . '</direct_trade_create_req>';
$request_data = $this->buildSignedParameters(array('service' => $this->service, 'partner' => $this->config['partner'], 'sec_id' => $this->config['sign_type'], 'format' => 'xml', 'v' => '2.0', 'req_id' => $params['req_id'], 'req_data' => $xml_str, '_input_charset' => $this->config['input_charset']));
$url = $this->alipay_gateway;
$input_charset = trim(strtolower($this->config['input_charset']));
if (trim($input_charset) != '') {
$url = $url . "_input_charset=" . $input_charset;
}
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
//SSL證書認證
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
//嚴格認證
curl_setopt($curl, CURLOPT_CAINFO, $this->config['cacert']);
//證書地址
curl_setopt($curl, CURLOPT_HEADER, 0);
// 過濾HTTP頭
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// 顯示輸出結果
curl_setopt($curl, CURLOPT_POST, true);
// post傳輸數據
curl_setopt($curl, CURLOPT_POSTFIELDS, $request_data);
// post傳輸數據
$responseText = curl_exec($curl);
//var_dump( curl_error($curl) );//如果執行curl過程中出現異常,可打開此開關,以便查看異常內容
curl_close($curl);
parse_str($responseText, $responseData);
if (!empty($responseData['res_data'])) {
if ($this->config['sign_type'] == '0001') {
$responseData['res_data'] = rsaDecrypt($responseData['res_data'], $this->config['private_key_path']);
}
//token從res_data中解析出來(也就是說res_data中已經包含token的內容)
$doc = new DOMDocument();
$doc->loadXML($responseData['res_data']);
$responseData['request_token'] = $doc->getElementsByTagName("request_token")->item(0)->nodeValue;
}
$xml_str = '<auth_and_execute_req>' . '<request_token>' . $responseData['request_token'] . '</request_token>' . '</auth_and_execute_req>';
return array('service' => 'alipay.wap.auth.authAndExecute', 'partner' => $this->config['partner'], 'sec_id' => $this->config['sign_type'], 'format' => 'xml', 'v' => '2.0', 'req_data' => $xml_str);
}
示例6: parseResponse
public function parseResponse($str_text)
{
$str_text = urldecode($str_text);
//URL轉碼
$para_split = explode('&', $str_text);
$data = array();
foreach ($para_split as $item) {
$nPos = strpos($item, '=');
$nLen = strlen($item);
$key = substr($item, 0, $nPos);
$value = substr($item, $nPos + 1, $nLen - $nPos - 1);
$data[$key] = $value;
}
if (!empty($data['res_data'])) {
if ($this->getSignType() == '0001') {
$data['res_data'] = rsaDecrypt($data['res_data'], $this->getPrivateKey());
}
$doc = new DOMDocument();
$doc->loadXML($data['res_data']);
$data['request_token'] = $doc->getElementsByTagName("request_token")->item(0)->nodeValue;
}
return $data;
}