@@ 94-102 (lines=9) @@ | ||
91 | } |
|
92 | ||
93 | protected function sign($data, $signType = "RSA") { |
|
94 | if($this->checkEmpty($this->rsaPrivateKeyFilePath)){ |
|
95 | $priKey=$this->rsaPrivateKey; |
|
96 | $res = "-----BEGIN RSA PRIVATE KEY-----\n" . |
|
97 | wordwrap($priKey, 64, "\n", true) . |
|
98 | "\n-----END RSA PRIVATE KEY-----"; |
|
99 | }else { |
|
100 | $priKey = file_get_contents($this->rsaPrivateKeyFilePath); |
|
101 | $res = openssl_get_privatekey($priKey); |
|
102 | } |
|
103 | ||
104 | ($res) or die('您使用的私钥格式错误,请检查RSA私钥配置'); |
|
105 | ||
@@ 595-606 (lines=12) @@ | ||
592 | ||
593 | function verify($data, $sign, $rsaPublicKeyFilePath, $signType = 'RSA') { |
|
594 | ||
595 | if($this->checkEmpty($this->alipayPublicKey)){ |
|
596 | ||
597 | $pubKey= $this->alipayrsaPublicKey; |
|
598 | $res = "-----BEGIN PUBLIC KEY-----\n" . |
|
599 | wordwrap($pubKey, 64, "\n", true) . |
|
600 | "\n-----END PUBLIC KEY-----"; |
|
601 | }else { |
|
602 | //读取公钥文件 |
|
603 | $pubKey = file_get_contents($rsaPublicKeyFilePath); |
|
604 | //转换为openssl格式密钥 |
|
605 | $res = openssl_get_publickey($pubKey); |
|
606 | } |
|
607 | ||
608 | ($res) or die('支付宝RSA公钥错误。请检查公钥文件格式是否正确'); |
|
609 |