Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PHP中对请求数据进行数字签名_Php_Encryption - Fatal编程技术网

如何在PHP中对请求数据进行数字签名

如何在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

我需要使用SHA1RSA对数字签名进行数字签名我如何才能做到这一点

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密钥吗?如果密钥的两个部分都没有共享,那么由于无法计算相同的结果,所涉及的服务器如何验证某些内容是否确实已签名?我更新了上面的问题。谢谢