PHP中使用CER公钥的方法

来源:互联网 发布:东线德军 知乎 编辑:程序博客网 时间:2024/05/01 22:00

先用OPENSSL进行转换


 openssl x509 -inform der -in pub.cer -out pub.pem


公钥通常没有密码保护


此时 此密钥文件 即可由PHP使用

$pubKey=openssl_get_publickey(file_get_contents("pub.pem"));
//公钥加密$encrypted = '';openssl_public_encrypt($data, $encrypted, $pubKey);//BASE64编码return base64_encode($encrypted);



原创粉丝点击