PHP的RSA加密解密方法以及开发接口使用(2)

<?php /** * Author: Wei ZhiHua * Date: 2017/6/30 0030 * Time: 上午 10:15 */ header('Content-Type:text/html;Charset=utf-8;'); include "RSA.php"; echo '<pre>'; $pubfile = 'D:\WWW\test\rsa_public_key.pem'; $prifile = 'D:\WWW\test\rsa_private_key.pem'; $rsa = new RSA($pubfile, $prifile); $rst = array( 'ret' => 200, 'code' => 1, 'data' => array(1, 2, 3, 4, 5, 6), 'msg' => "success", ); $ex = json_encode($rst); //加密 $ret_e = $rsa->encrypt($ex); //解密 $ret_d = $rsa->decrypt($ret_e); echo $ret_e; echo '<pre>'; echo $ret_d; echo '<pre>'; $a = 'test'; //签名 $x = $rsa->sign($a); //验证 $y = $rsa->verify($a, $x); var_dump($x, $y); exit;

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/797c64e6dd594508b690a0cca1edf883.html