From 45c63499d8bf58a8a44d8142bf93ffaf299166da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=AF=E6=98=8E=E6=85=A7?= <1191093413@qq.com> Date: Tue, 27 Feb 2024 17:57:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=AF=86=EF=BC=9A=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=88=A4=E6=96=AD=E5=92=8C=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jianshui/web/controller/sandbox/IndexController.java | 9 +++++++-- .../common/utils/encrypt/InvoiceEncryptUtil.java | 4 ++++ jianshui-ui/src/views/sandbox/encrypt.vue | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/jianshui-admin/src/main/java/com/jianshui/web/controller/sandbox/IndexController.java b/jianshui-admin/src/main/java/com/jianshui/web/controller/sandbox/IndexController.java index 68f44c9..a63ea54 100644 --- a/jianshui-admin/src/main/java/com/jianshui/web/controller/sandbox/IndexController.java +++ b/jianshui-admin/src/main/java/com/jianshui/web/controller/sandbox/IndexController.java @@ -22,7 +22,12 @@ public class IndexController { public AjaxResult encrypt(@RequestBody JSONObject requestBody) { String key = requestBody.getString("key"); String order = requestBody.getString("order"); - String encryptTest = InvoiceEncryptUtil.encrypt(order, key); - return AjaxResult.success("success", encryptTest); + try { + String encryptTest = InvoiceEncryptUtil.encrypt(order, key); + return AjaxResult.success("success", encryptTest); + }catch (Exception e){ + return AjaxResult.error(e.getMessage()); + } + } } diff --git a/jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/InvoiceEncryptUtil.java b/jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/InvoiceEncryptUtil.java index ca2e2d6..7cab596 100644 --- a/jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/InvoiceEncryptUtil.java +++ b/jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/InvoiceEncryptUtil.java @@ -174,6 +174,10 @@ public class InvoiceEncryptUtil { buf = decoder.decodeBuffer(encryptKey); } catch (IOException e) { e.printStackTrace(); + throw new RuntimeException("加密key处理失败"); + } + if (buf != null && buf.length < 16) { + throw new RuntimeException("加密key长度不够"); } // 前8位为key int i; diff --git a/jianshui-ui/src/views/sandbox/encrypt.vue b/jianshui-ui/src/views/sandbox/encrypt.vue index 9f58fd0..9a8952d 100644 --- a/jianshui-ui/src/views/sandbox/encrypt.vue +++ b/jianshui-ui/src/views/sandbox/encrypt.vue @@ -33,6 +33,7 @@ export default { }, methods: { onSubmit() { + this.requestBody.resp = "" encrypt(this.requestBody).then(res => { if (res.code == 200) { this.requestBody.resp = res.data