本文整理汇总了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;
}