公钥加密处理报错, openssl_public_encrypt(): key parameter is not a valid public key
1.开启open_ssl扩展
2.转化再加密
下载的公钥形式类似 '-----BEGIN PUBLIC KEY----- MIGTDVGHWDFNADCBiQKBgQ99XZ6WiHxh94IAKTgSOEev 6tASj3XKVnssChGIZaSvdRXiJshGaR1LNeDbWSDFWE8OjA9sPlwgLJabnP WR283fGu7nRm9/sc4HKRETEF2bj7rcMeEAQAB -----END PUBLIC KEY-----'
去掉 、/,
$str = str_replace(array(" ", " ", " "), "", $str);
$this->public_key = 'MIGTDVGHWDFNADCBiQKBgQ99XZ6WiHxh94IAKTgSOEev6tASj3XKVnssChGIZaSvdRXiJshGaR1LNeDbWSDFWE8OjA9sPlwgLJabnPWR283fGu7nRm9sc4HKRETEF2bj7rcMeEAQAB';
再重新拼接 "-----BEGIN PUBLIC KEY----- " . wordwrap($this->public_key, 64, " ", true) . " -----END PUBLIC KEY-----"用来加密