参考文档为微信平台小微入驻文档
/**
* publicKeyEncrypt 对身份证等敏感信息加密
* @param string $string
* @return string
* @throws WxException
*/
protected function publicKeyEncrypt(string $string)
{
$crypted = '';
$publicKey = $this->getPublicKey();
if ($publicKey) {
$publicKeyResource = openssl_get_publickey($publicKey);
$f = openssl_public_encrypt($string, $crypted, $publicKeyResource, OPENSSL_PKCS1_PADDING);
openssl_free_key($publicKeyResource);
if ($f) {
return base64_encode($crypted);
}
}
throw new WxException(20002);
}
/**
* MakeSign 生成签名
* @param $data
* @param string $signType
* @return string
*/
protected function makeSign(array $data, $signType = 'HMAC-SHA256')
{
//签名