From 6aefd41520bb2b34bcf3ef042539e06181d83ace Mon Sep 17 00:00:00 2001
From: wangxy <1356089412@qq.com>
Date: Thu, 9 May 2024 08:47:00 +0800
Subject: [PATCH] =?UTF-8?q?fix:=E6=95=B0=E6=8D=AE=E5=BA=93=E5=AF=86?=
=?UTF-8?q?=E7=A0=81=E5=8A=A0=E5=AF=86=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ruoyi-admin/pom.xml | 7 ++++++
.../src/main/resources/application-druid.yml | 6 +++--
.../src/main/resources/application.yml | 5 ++++
.../src/test/java/com/ruoyi/EncFactory.java | 23 +++++++++++++++++++
4 files changed, 39 insertions(+), 2 deletions(-)
create mode 100644 ruoyi-admin/src/test/java/com/ruoyi/EncFactory.java
diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml
index 60d3a72..f5f07b5 100644
--- a/ruoyi-admin/pom.xml
+++ b/ruoyi-admin/pom.xml
@@ -67,6 +67,13 @@
ruoyi-generator
+
+
+ com.github.ulisesbocchio
+ jasypt-spring-boot-starter
+ 2.1.0
+
+
diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml
index c8d784b..5f01c1e 100644
--- a/ruoyi-admin/src/main/resources/application-druid.yml
+++ b/ruoyi-admin/src/main/resources/application-druid.yml
@@ -7,8 +7,10 @@ spring:
# 主库数据源
master:
url: jdbc:mysql://192.168.254.123:3306/zhky?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
- username: root
- password: qwer1234
+ #username: root
+ #password: qwer1234
+ username: ENC(ElFzIjuV3codlxGotvqqyA==)
+ password: ENC(aM81j4MP4WJC4ZQBNlDntx0jKsP3wwQZ)
# 从库数据源
slave:
# 从数据源开关/默认关闭
diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index c820ef1..46198f5 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -154,3 +154,8 @@ aj:
aes-status: true
# 滑动干扰项(0/1/2)
interference-options: 0
+
+#解析密钥
+jasypt:
+ encryptor:
+ password: BUSINESS
diff --git a/ruoyi-admin/src/test/java/com/ruoyi/EncFactory.java b/ruoyi-admin/src/test/java/com/ruoyi/EncFactory.java
new file mode 100644
index 0000000..21e7eb7
--- /dev/null
+++ b/ruoyi-admin/src/test/java/com/ruoyi/EncFactory.java
@@ -0,0 +1,23 @@
+package com.ruoyi;
+
+import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
+import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
+
+public class EncFactory {
+ public static void main(String[] args) {
+ String securityKey = "BUSINESS"; // 加密秘钥
+ String data = "qwer1234"; // 需要加密的字符串
+
+ PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
+ SimpleStringPBEConfig config = new SimpleStringPBEConfig();
+ config.setPassword(securityKey);
+ config.setAlgorithm("PBEWithMD5AndDES");
+ config.setPoolSize("1");
+ config.setStringOutputType("base64");
+ encryptor.setConfig(config);
+
+ System.out.println("ENC("+ encryptor.encrypt(data) +")");
+ System.out.println(encryptor.decrypt("t3TY7+QFjQNRv8N833J1PRV6+/QTBwJP"));
+
+ }
+}