up. 双向数据加密
This commit is contained in:
parent
29bf079731
commit
11a226c417
@ -23,8 +23,8 @@ class ContextMiddleware extends middleware
|
||||
if ($request->header('x-encrypted') == 'true') {
|
||||
$encryptedData = $request->param('encryptedData','');
|
||||
if($encryptedData) {
|
||||
$jsonData = $this->decryptCryptoJSData($encryptedData);
|
||||
$request->withPost($jsonData);
|
||||
$jsonInput = $this->decryptCryptoJSData($encryptedData);
|
||||
$request->withInput($jsonInput);
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ class ContextMiddleware extends middleware
|
||||
* @return array 解密后的数据
|
||||
* @throws ValidateException 解密失败时抛出异常
|
||||
*/
|
||||
private function decryptCryptoJSData(string $encryptedData): array
|
||||
private function decryptCryptoJSData(string $encryptedData): string
|
||||
{
|
||||
// Base64解码
|
||||
$data = base64_decode($encryptedData);
|
||||
@ -188,7 +188,7 @@ class ContextMiddleware extends middleware
|
||||
OPENSSL_RAW_DATA,
|
||||
$iv
|
||||
);
|
||||
return json_decode($decrypted, true);
|
||||
return $decrypted;
|
||||
}
|
||||
|
||||
private function evpBytesToKey($salt): array
|
||||
|
||||
Loading…
Reference in New Issue
Block a user