public function getSign($data,$key){
foreach ($data as $k => $v)
{
$Parameters[$k] = $v;
}
//签名步骤一:按字典序排序参数
ksort($Parameters);
$data = $this->formatBizQueryParaMap($Parameters, false);
$sign = $this->SHA1withRSA($data,$key);
// //签名步骤二:在string后加入KEY
// $String = $String."&key=".$key;
// //签名步骤三:MD5加密
// $String = md5($String);
// //签名步骤四:所有字符转为大写
// $result = strtoupper($String);
return $sign;
}
public function SHA1withRSA($data,$key){
$certs = array();
openssl_pkcs12_read(file_get_contents($key), $certs, "1106@123"); //其中1106@123为你的证书密码
if(!$certs) return ;
$signature = '';
openssl_sign($data, $signature, $certs['pkey']);
return base64_encode($signature);
}
php SHA1withRSA算法签名
猜你喜欢
转载自blog.csdn.net/qq_38083665/article/details/80720182
今日推荐
周排行