| | |
| | | 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("加密失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |