From 73f17313885ac328d99f41c83e997825c6f7d8aa Mon Sep 17 00:00:00 2001 From: wangxy <1481820854@qq.com> Date: Sat, 14 Dec 2024 11:02:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/pom.xml | 8 +++++++ .../src/main/resources/application-dev.yml | 4 ++-- .../src/main/resources/application.yml | 5 ++++ .../src/test/java/com/ruoyi/EncFactory.java | 23 +++++++++++++++++++ 4 files changed, 38 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 557a2ce..18cdc4e 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -71,6 +71,14 @@ com.ruoyi ruoyi-flow + + + + com.github.ulisesbocchio + jasypt-spring-boot-starter + 2.1.0 + + org.springframework.boot spring-boot-starter-test diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index 9b60936..83e6135 100644 --- a/ruoyi-admin/src/main/resources/application-dev.yml +++ b/ruoyi-admin/src/main/resources/application-dev.yml @@ -7,8 +7,8 @@ spring: # 主库数据源 master: url: jdbc:kingbase8://61.178.84.89:54321/ry_vue-test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&clientEncoding=UTF8 - username: root - password: 123456 + username: ENC(HwzyzJMA3KwPMWUgtxUR9w==) + password: ENC(JcBUXyJAPqtYOO+qSvHccg==) # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 95c2a05..a3471e5 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -135,6 +135,11 @@ swagger: # 请求前缀 pathMapping: /dev-api +#解析密钥 +jasypt: + encryptor: + password: MANAGER + # 防止XSS攻击 xss: # 过滤开关 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..5320a87 --- /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 = "MANAGER"; // 加密秘钥 + String data = "123456"; // 需要加密的字符串 + + 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")); + + } +}