|
@@ -166,6 +166,27 @@ class Api
|
|
|
*/
|
|
|
protected function success($msg = '', $data = null, $code = 1, $type = null, array $header = [])
|
|
|
{
|
|
|
+ if ($data) {
|
|
|
+ //手机号/微信号 私钥加密
|
|
|
+ $private_key = "-----BEGIN RSA PRIVATE KEY-----" .PHP_EOL.
|
|
|
+ wordwrap(config('private_key'), 64, PHP_EOL, true) .
|
|
|
+ PHP_EOL."-----END RSA PRIVATE KEY-----";
|
|
|
+ if (isset($data['mobile']) && $data['mobile']) {
|
|
|
+ $mobile = "";
|
|
|
+ openssl_private_encrypt($data['mobile'], $mobile, $private_key); // 使用私钥加密数据
|
|
|
+ $data['mobile'] = base64_encode($mobile);
|
|
|
+ }
|
|
|
+ if (isset($data['wechat']) && $data['wechat']) {
|
|
|
+ $wechat = "";
|
|
|
+ openssl_private_encrypt($data['wechat'], $wechat, $private_key); // 使用私钥加密数据
|
|
|
+ $data['wechat'] = base64_encode($wechat);
|
|
|
+ }
|
|
|
+ if (isset($data['wechat_auth']) && $data['wechat_auth']) {
|
|
|
+ $wechat_auth = "";
|
|
|
+ openssl_private_encrypt($data['wechat_auth'], $wechat_auth, $private_key); // 使用私钥加密数据
|
|
|
+ $data['wechat_auth'] = base64_encode($wechat_auth);
|
|
|
+ }
|
|
|
+ }
|
|
|
$this->result($msg, $data, $code, $type, $header);
|
|
|
}
|
|
|
|