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

时间:2015-05-03 08:59:47

标签: 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($encrypted);
        else
            throw new Exception('Unable to encrypt data. Perhaps it is bigger than the key size?');

        return $data;
    }
}

1 个答案:

答案 0 :(得分:2)

我不会在应用程序级别上处理它。使用ssl(HTTPS)的所有功能应该适合您。