From 48dd95b28f220f3cae4cae265f19862f4e874ced Mon Sep 17 00:00:00 2001 From: CeDo <cedoogle@gmail.com> Date: 星期四, 01 四月 2021 18:20:22 +0800 Subject: [PATCH] bug fixed:解密异常处理 --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/helper/encrypt/DoEncrytDecrypt.java | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/helper/encrypt/DoEncrytDecrypt.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/helper/encrypt/DoEncrytDecrypt.java index 5c7e621..d67c1bb 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/helper/encrypt/DoEncrytDecrypt.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/helper/encrypt/DoEncrytDecrypt.java @@ -32,8 +32,12 @@ log.debug("加密字段:" + field.getName()); Object fieldVal = field.get(parameterObject); if(fieldVal!=null) { - String encryptedStr = AESUtil.encrypt128(fieldVal.toString(), aesKey); - field.set(parameterObject, encryptedStr); + try { + String encryptedStr = AESUtil.encrypt128(fieldVal.toString(), aesKey); + field.set(parameterObject, encryptedStr); + }catch (Exception e){ + log.debug("加密失败"); + } } } } @@ -53,8 +57,15 @@ if (annotation.annotationType() == EncryptDecryptField.class) { log.debug("解密密字段:" + field.getName()); String fieldVal = field.get(result).toString(); - String decryptVal = AESUtil.decrypt128(fieldVal, aesKey); - field.set(result, decryptVal!=null?decryptVal:fieldVal); + try { + String decryptVal = AESUtil.decrypt128(fieldVal, aesKey); + field.set(result, decryptVal != null ? decryptVal : fieldVal); + }catch (Exception e){ + /** + * 兼容原始未加密数据 + */ + field.set(result, fieldVal); + } } } } -- Gitblit v1.7.1