add clear

This commit is contained in:
as2252258@163.com
2019-07-03 19:07:12 +08:00
parent 7aca3cf1e4
commit c6e9b9a34d
+7 -9
View File
@@ -339,7 +339,9 @@ abstract class Base
/** /**
* @param $encryptedData * @param $encryptedData
* @param $iv * @param $iv
* @param $sessionKey
* @param $data * @param $data
* @param null $appId
* @return int * @return int
*/ */
public static function decode($encryptedData, $iv, $sessionKey, &$data, $appId = null) public static function decode($encryptedData, $iv, $sessionKey, &$data, $appId = null)
@@ -348,25 +350,21 @@ abstract class Base
return self::$IllegalAesKey; return self::$IllegalAesKey;
} }
flush();
$aesKey = base64_decode($sessionKey); $aesKey = base64_decode($sessionKey);
if (strlen($iv) != 24) { if (strlen($iv) != 24) {
return self::$IllegalIv; return self::$IllegalIv;
} }
$aesIV = base64_decode($iv); $aesIV = base64_decode($iv);
$aesCipher = base64_decode($encryptedData); $aesCipher = base64_decode($encryptedData);
flush(); $result = openssl_decrypt($aesCipher, "AES-128-CBC", $aesKey, OPENSSL_RAW_DATA, $aesIV);
$result = openssl_decrypt($aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV); if ($result === false) {
$dataObj = json_decode($result);
if ($dataObj == NULL) {
return self::$IllegalBuffer; return self::$IllegalBuffer;
} }
if (empty($appId)) {
$appId = static::$appid; $dataObj = json_decode($result);
}
if ($dataObj->watermark->appid != $appId) { if ($dataObj->watermark->appid != $appId) {
return self::$IllegalBuffer; return self::$IllegalBuffer;
} }