【发布时间】:2022-01-17 08:56:06
【问题描述】:
我用 PHP 编写了这两个方法。 第一个方法 get_pubkey 从证书 (certnew.cer) 中提取公钥,第二个方法 encryptit(info) 使用第一个函数提取的公钥返回加密信息。 我需要将这 2 个函数移植到它们的 Javascript 等效函数。有人知道怎么做吗?
class Assdig
{
private $pubkey;
/* (... )*/
public function get_pubkey()
{
$certificado = __DIR__ . '/certnew.cer';
$fp=fopen($certificado,"r");
$this->pubkey=fread($fp,8192);
fclose($fp);
openssl_get_publickey($this->pubkey);
}
public function encryptit($info)
{
openssl_public_encrypt($info, $infoencrypted, $this->pubkey);
return base64_encode($infoencrypted);
}
}
【问题讨论】:
标签: javascript php encryption