getTraceAsString(); } } /** * 私钥解密 * @param type $Data 解密数据 * @param type $PublicPath 解密公钥路径 * @return type * @throws Exception */ public static function decryptByPFXFile($Data,$PfxPath,$PrivateKPASS){ try { if (!function_exists( 'hex2bin')) { throw new Exception("hex2bin PHP5.4及以上版本支持此函数,也可自行实现!"); } $KeyObj = self::ReadPrivateKey($PfxPath,$PrivateKPASS); $DecryptRsult=""; $blockSize=256;//分段长度 $totalLen = strlen($Data); $EncryptSubStarLen = 0; $DecryptTempData=""; while ($EncryptSubStarLen < $totalLen) { openssl_private_decrypt(hex2bin(substr($Data, $EncryptSubStarLen, $blockSize)), $DecryptTempData, $KeyObj); $DecryptRsult .= $DecryptTempData; $EncryptSubStarLen += $blockSize; } return base64_decode($DecryptRsult); } catch (Exception $exc) { echo $exc->getTraceAsString(); } } } ?>