如何在PHP中对请求数据进行数字签名
我需要使用SHA1RSA对数字签名进行数字签名我如何才能做到这一点如何在PHP中对请求数据进行数字签名,php,encryption,Php,Encryption,我需要使用SHA1RSA对数字签名进行数字签名我如何才能做到这一点 class MyEncryption { public $pubkey = '...public key here...'; public function encrypt($data) { if (openssl_public_encrypt($data, $encrypted, $this->pubkey)) $data = base64_encode
class MyEncryption
{
public $pubkey = '...public key here...';
public function encrypt($data)
{
if (openssl_public_encrypt($data, $encrypted, $this->pubkey))
$data = base64_encode($encrypted);
else
throw new Exception('Unable to encrypt data. Perhaps it is bigger than the key size?');
return $data;
}
}
我不会在应用程序级别处理这个问题。使用
ssl
(HTTPS)的所有功能应该适合您。您不应该与服务器共享您的RSA密钥吗?如果密钥的两个部分都没有共享,那么由于无法计算相同的结果,所涉及的服务器如何验证某些内容是否确实已签名?我更新了上面的问题。谢谢