setKey($aeskey); //解密AES密文 $plaintext = $aes->decrypt(base64_decode($crypttext)); echo $plaintext; echo ''; //AES加密明文 //echo $aes->encrypt($plaintext); //rsa公钥 $publickey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCffOeIVYut9jW5w1L5uKX4aDvd837a8JhaWm5S8YqNQfgEmfD9T+rDknXLqMT+DXeQAqGo4hBmcbej1aoMzn6hIJHk3/TfTAToNN8fgwDotHewsTCBbVkQWtDTby3GouWToVsRi1i/A0Vfb0+xM8MnF46DdhhrnZrycERBSbyrcwIDAQAB'; //echo base64_decode($publickey); //rsa签名 $signature = 'XHin4uUFqrKDEhKBD/hQisXLFFSxM6EZCvCPqnWCQJq3uEp3ayxmFuUgVE0Xoh4AIWjIIsOWdnaToL1bXvAFKwjCtXnkaRwUpvWrk+Q0eqwsoAdywsVQDEceG5stas1CkPtrznAIW2eBGXCWspOj+aumEAcPyYDxLhDN646Krzw='; //echo base64_decode($signature); $rsa = new Crypt_RSA(); //设置RSA签名模式 CRYPT_RSA_SIGNATURE_PSS or CRYPT_RSA_SIGNATURE_PKCS1 $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); //var_dump($rsa->createKey()); //生成RSA公钥、私钥 //extract($rsa->createKey()); //使用RSA私钥生成签名 //$rsa->loadKey($privatekey); //$signature = $rsa->sign($plaintext); //使用RSA公钥验证签名 echo $plaintext; $rsa->loadKey(base64_decode($publickey)); echo $rsa->verify($plaintext, base64_decode($signature)) ? 'verified' : 'unverified'; echo ''; //生成RSA公钥、私钥 //var_dump($rsa->createKey()); extract($rsa->createKey()); //使用RSA私钥加密数据 $rsa->loadKey($privatekey); $ciphertext = $rsa->encrypt($plaintext); //使用RSA公钥解密数据 $rsa->loadKey($publickey); echo $rsa->decrypt($ciphertext);