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")); + + } +}