王总上门按摩后台代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
811 B

2 months ago
<?php
namespace app\Common;
class Rsa2
{
private $private_key;
private $public_key;
private $config = array(
"digest_alg" => "sha512",
"private_key_bits" =>2048,
"private_key_type" => OPENSSL_KEYTYPE_RSA
);
function __construct(){
$res = openssl_pkey_new($this->config);
//生成私钥
openssl_pkey_export($res, $this->private_key, null, $this->config);
//生成公钥
$this->public_key = openssl_pkey_get_details($res)['key'];
}
public function getKeys() {
$result = [];
if(!empty($this->private_key)) $result['private_key'] =$this->private_key;
if(!empty($this->public_key)) $result['public_key'] =$this->public_key;
return $result;
}
}