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