up. 双向数据加密
This commit is contained in:
parent
593381f119
commit
701610d683
@ -24,6 +24,9 @@ class ContextMiddleware extends middleware
|
|||||||
$encryptedData = $request->param('encryptedData','');
|
$encryptedData = $request->param('encryptedData','');
|
||||||
if($encryptedData) {
|
if($encryptedData) {
|
||||||
$jsonInput = $this->decryptCryptoJSData($encryptedData);
|
$jsonInput = $this->decryptCryptoJSData($encryptedData);
|
||||||
|
if($jsonInput) {
|
||||||
|
return json(['code'=>500,'message'=>'E0.数据解密失败']);
|
||||||
|
}
|
||||||
$request->withInput($jsonInput);
|
$request->withInput($jsonInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,14 +184,13 @@ class ContextMiddleware extends middleware
|
|||||||
$iv = $keyIv['iv'];
|
$iv = $keyIv['iv'];
|
||||||
|
|
||||||
// AES-256-CBC解密
|
// AES-256-CBC解密
|
||||||
$decrypted = openssl_decrypt(
|
return openssl_decrypt(
|
||||||
$ct,
|
$ct,
|
||||||
'aes-256-cbc',
|
'aes-256-cbc',
|
||||||
$key,
|
$key,
|
||||||
OPENSSL_RAW_DATA,
|
OPENSSL_RAW_DATA,
|
||||||
$iv
|
$iv
|
||||||
);
|
);
|
||||||
return $decrypted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function evpBytesToKey($salt): array
|
private function evpBytesToKey($salt): array
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user