This commit is contained in:
weiye 2020-03-24 18:19:11 +08:00
parent 7bce036997
commit 39cd3ca3fa
2 changed files with 11 additions and 4 deletions

View File

@ -57,7 +57,7 @@ public class AESUtil {
return new Base64().encodeToString(result); // 加密
}
} catch (Exception e) {
log.error("content encrypt error {0}",e);
log.error("content encrypt error {}",e.getMessage());
}
return null;
}
@ -81,7 +81,7 @@ public class AESUtil {
return new String(result); // 解密
}
} catch (Exception e) {
log.error("content decrypt error {0}",e);
log.error("content decrypt error {}",e.getMessage());
}
return null;
}

View File

@ -40,8 +40,15 @@ public class JSONUtils {
public static JSONObject decrypt(String content, String key) {
JSONObject writer = JSONObject.parseObject(JSONObject.parseObject(content).getString(key));
JSONObject writerParams = JSONObject.parseObject(writer.getString("parameter"));
writerParams.put("username", AESUtil.decrypt(writerParams.getString("username")));
writerParams.put("password", AESUtil.decrypt(writerParams.getString("password")));
String dUsername = AESUtil.decrypt(writerParams.getString("username"));
String username = dUsername == null ? writerParams.getString("username") : dUsername;
writerParams.put("username", username);
String dPassword = AESUtil.decrypt(writerParams.getString("password"));
String password = dPassword == null ? writerParams.getString("password") : dPassword;
writerParams.put("password", password);
writer.put("parameter", writerParams);
return writer;
}