加密:优化异常判断和返回提示

beta
路明慧 1 year ago
parent a6b7f39ad4
commit 45c63499d8
  1. 9
      jianshui-admin/src/main/java/com/jianshui/web/controller/sandbox/IndexController.java
  2. 4
      jianshui-common/src/main/java/com/jianshui/common/utils/encrypt/InvoiceEncryptUtil.java
  3. 1
      jianshui-ui/src/views/sandbox/encrypt.vue

@ -22,7 +22,12 @@ public class IndexController {
public AjaxResult encrypt(@RequestBody JSONObject requestBody) { public AjaxResult encrypt(@RequestBody JSONObject requestBody) {
String key = requestBody.getString("key"); String key = requestBody.getString("key");
String order = requestBody.getString("order"); String order = requestBody.getString("order");
String encryptTest = InvoiceEncryptUtil.encrypt(order, key); try {
return AjaxResult.success("success", encryptTest); String encryptTest = InvoiceEncryptUtil.encrypt(order, key);
return AjaxResult.success("success", encryptTest);
}catch (Exception e){
return AjaxResult.error(e.getMessage());
}
} }
} }

@ -174,6 +174,10 @@ public class InvoiceEncryptUtil {
buf = decoder.decodeBuffer(encryptKey); buf = decoder.decodeBuffer(encryptKey);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException("加密key处理失败");
}
if (buf != null && buf.length < 16) {
throw new RuntimeException("加密key长度不够");
} }
// 前8位为key // 前8位为key
int i; int i;

@ -33,6 +33,7 @@ export default {
}, },
methods: { methods: {
onSubmit() { onSubmit() {
this.requestBody.resp = ""
encrypt(this.requestBody).then(res => { encrypt(this.requestBody).then(res => {
if (res.code == 200) { if (res.code == 200) {
this.requestBody.resp = res.data this.requestBody.resp = res.data

Loading…
Cancel
Save