证书的加密解密方法
加密方法(字符串 ,证书地址,证书密码)sha256是加密的算法 ()()()()()公钥加密私钥解密
function sign($data,$pfxpath,$pfxpwd) {
    $certs = array();
    openssl_pkcs12_read(file_get_contents($pfxpath), $certs, $pfxpwd); // 其中password为你的证书密码
    if (!$certs) {
		return;
	}
    $signature = '';  
    openssl_sign($data, $signature, $certs['pkey'],'sha256');
    return base64_encode($signature); 
}
解密(字符串,加密的$signature,证书地址)
function verify($data, $signature, $publicKeyName){
	$result = (bool)openssl_verify($data, base64_decode($signature), file_get_contents($publicKeyName), 'sha256');
	return $result;
}
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号