示例#1
0
 /**
  * 3DES 解密 进行了补位的16进制表示的字符串数据
  *
  * @param $keys
  * @param $data
  * @return string
  */
 public static function decrypt4HexStr($keys, $data)
 {
     $hexSourceData = array();
     $hexSourceData = ByteUtils::hexStrToBytes($data);
     //var_dump($hexSourceData);
     // 解密
     $unDesResult = TDESUtil::decrypt(ByteUtils::toStr($hexSourceData), $keys);
     //echo $unDesResult;
     $unDesResultByte = ByteUtils::getBytes($unDesResult);
     //var_dump($unDesResultByte);
     $dataSizeByte = array();
     for ($i = 0; $i < 4; $i++) {
         $dataSizeByte[$i] = $unDesResultByte[$i];
     }
     // 有效数据长度
     $dsb = ByteUtils::byteArrayToInt($dataSizeByte, 0);
     $tempData = array();
     for ($j = 0; $j < $dsb; $j++) {
         $tempData[$j] = $unDesResultByte[4 + $j];
     }
     return ByteUtils::hexTobin(ByteUtils::bytesToHex($tempData));
 }
示例#2
0
文件: JD.php 项目: zrone/JDproject
 /**
  * @zrone\NAME   封装退款表单参数
  * @zrone\DETAIL 订单里需要加字段验证
  *
  * @param array $formData
  *
  * @return array
  */
 public static function filterRefundFormData(array $formData)
 {
     $param = array();
     $param['merchantNum'] = self::$_merchant;
     // 商户号
     $param["version"] = '1.0';
     // 退款版本号
     $data = array('tradeNum' => isset($formData["tradeNum"]) ? $formData["tradeNum"] : "", 'oTradeNum' => isset($formData["oTradeNum"]) ? $formData["oTradeNum"] : "", 'tradeAmount' => isset($formData["tradeAmount"]) ? $formData["tradeAmount"] : 0, 'tradeCurrency' => 'CNY', 'tradeDate' => date("Ymd", $_SERVER['REQUEST_TIME']), 'tradeTime' => date("His", $_SERVER['REQUEST_TIME']), 'tradeNotice' => self::$_serverRefundUrl, 'tradeNote' => isset($formData["tradeNote"]) ? $formData["tradeNote"] : "");
     $param['data'] = TDESUtil::encrypt2HexStr(base64_decode(self::$_DES), json_encode($data));
     $tradeData = hash("sha256", $param['data']);
     $param["merchantSign"] = RSAUtils::encryptByPrivateKey($tradeData);
     return $param;
 }