1.需要开启PHP的php_openssl扩展;
2.生成公钥和密钥;
<?php
header("Content-type:text/html;charset=utf-8");
$configargs = array('config'=>'D:\php\extras\openssl\opensslf'); //路径
$res = openssl_pkey_new($configargs);
openssl_pkey_export($res,$pri, null, $configargs);
$d= openssl_pkey_get_details($res);
$pub = $d['key'];
var_dump($pri,$pub);
die;
<?php
$binary_signature = "";
$algo = "SHA256";
openssl_sign($sign, $binary_signature, $prikey, $algo);
$sign = base64_encode($binary_signature);
更多推荐
SHA256WithRSA签名算法(PHP实现)
发布评论