Ejemplo n.º 1
0
 public function checkSign()
 {
     $param = array();
     $param["token"] = $_GET["token"];
     $param["tradeAmount"] = $_GET["tradeAmount"];
     $param["tradeCurrency"] = $_GET["tradeCurrency"];
     $param["tradeDate"] = $_GET["tradeDate"];
     $param["tradeNote"] = $_GET["tradeNote"];
     $param["tradeNum"] = $_GET["tradeNum"];
     $param["tradeStatus"] = $_GET["tradeStatus"];
     $param["tradeTime"] = $_GET["tradeTime"];
     $data = SignUtil::signString($param, SignUtil::$unSignKeyList);
     error_log($data, 0);
     //1.解密签名内容
     $decryptStr = RSAUtils::decryptByPublicKey($_GET["sign"]);
     //2.对data进行sha256摘要加密
     $sha256SourceSignString = hash("sha256", $data);
     error_log($decryptStr, 0);
     error_log($sha256SourceSignString, 0);
     //3.比对结果
     if ($decryptStr == $sha256SourceSignString) {
         $_SESSION['errorMsg'] = $_GET["tradeNum"] . ":验签成功";
     } else {
         $_SESSION['errorMsg'] = "验证签名失败!";
     }
     header("location:../tpl/payResult.php");
 }
Ejemplo n.º 2
0
 public function prepareParms()
 {
     $tradeJsonData = "{\"tradeNum\": \"" . $_POST["tradeNum"] . "\",\"oTradeNum\": \"" . $_POST["oTradeNum"] . "\",\"tradeAmount\":\"" . $_POST["tradeAmount"] . "\",\"tradeCurrency\": \"" . $_POST["tradeCurrency"] . "\",\"tradeDate\": \"" . $_POST["tradeDate"] . "\",\"tradeTime\": \"" . $_POST["tradeTime"] . "\",\"tradeNotice\": \"" . $_POST["tradeNotice"] . "\",\"tradeNote\": \"" . $_POST["tradeNote"] . "\"}";
     $tradeData = TDESUtil::encrypt2HexStr(base64_decode(ConfigUtil::get_val_by_key("desKey")), $tradeJsonData);
     $sha256SourceSignString = hash("sha256", $tradeData);
     $sign = RSAUtils::encryptByPrivateKey($sha256SourceSignString);
     $params = array();
     $params["version"] = $_POST["version"];
     $params["merchantNum"] = $_POST["merchantNum"];
     $params["merchantSign"] = $sign;
     $params["data"] = $tradeData;
     return $params;
 }
Ejemplo n.º 3
0
 public function prepareParms()
 {
     $tradeJsonData = "{\"tradeNum\": \"" . $_POST["tradeNum"] . "\"}";
     // 1.对交易信息进行3DES加密
     $tradeData = TDESUtil::encrypt2HexStr(base64_decode(ConfigUtil::get_val_by_key("desKey")), $tradeJsonData);
     // 2.对3DES加密的数据进行签名
     $sha256SourceSignString = hash("sha256", $tradeData);
     $sign = RSAUtils::encryptByPrivateKey($sha256SourceSignString);
     $params = array();
     $params["version"] = $_POST["version"];
     $params["merchantNum"] = $_POST["merchantNum"];
     $params["merchantSign"] = $sign;
     $params["data"] = $tradeData;
     return $params;
 }