Skip to content

Commit

Permalink
增加获取用户信息时的解密函数
Browse files Browse the repository at this point in the history
  • Loading branch information
abei2017 committed Sep 24, 2018
1 parent ac57b73 commit b15f1b3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/mini/user/User.php
Original file line number Diff line number Diff line change
@@ -34,4 +34,24 @@ public function codeToSession($code){
$data = $response->getData();
return $data;
}

/**
* 解密信息
* 主要用于wx.getUserInfo时对加密数据的解密。
*
* @param $sessionKey
* @param $iv
* @param $encryptedData
* @return mixed
* @since 1.3
*/
public function decryptData($sessionKey,$iv,$encryptedData){
$aesKey = base64_decode($sessionKey);
$aesIV = base64_decode($iv);
$aesCipher = base64_decode($encryptedData);
$result=openssl_decrypt( $aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV);

$dataObj = json_decode( $result );
return $dataObj;
}
}

0 comments on commit b15f1b3

Please sign in to comment.