up. 双向数据加密
This commit is contained in:
parent
73bd4b9a2b
commit
93f6b684d7
@ -23,13 +23,13 @@ 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) {
|
||||||
// try{
|
try{
|
||||||
$jsonInput = \app\Request::decryptCryptoJSData($encryptedData);
|
$jsonInput = \app\Request::decryptCryptoJSData($encryptedData);
|
||||||
// }catch (\Throwable){
|
}catch (\Throwable){
|
||||||
// $jsonInput = null;
|
$jsonInput = null;
|
||||||
// }
|
}
|
||||||
|
|
||||||
if($jsonInput) {
|
if(empty($jsonInput)) {
|
||||||
return json(['code'=>500,'message'=>'E0.数据解密失败']);
|
return json(['code'=>500,'message'=>'E0.数据解密失败']);
|
||||||
}
|
}
|
||||||
$request->withInput($jsonInput);
|
$request->withInput($jsonInput);
|
||||||
|
|||||||
@ -37,7 +37,6 @@ export function decryptData(ciphertext: string): any {
|
|||||||
if (!jsonString) {
|
if (!jsonString) {
|
||||||
throw new Error('Decryption failed: Invalid key or ciphertext');
|
throw new Error('Decryption failed: Invalid key or ciphertext');
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSON.parse(jsonString);
|
return JSON.parse(jsonString);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user