Compare commits

...

2 Commits

Author SHA1 Message Date
xiaocp2009
643d8bffd8 Merge remote-tracking branch 'origin/main' into main 2025-08-28 13:26:13 +08:00
xiaocp2009
a4776c07b8 增加参数加密 2025-08-28 13:25:44 +08:00
5 changed files with 63 additions and 4 deletions

View File

@ -0,0 +1,35 @@
package org.dromara.util;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
/**
* package: org.dromara.util
* creat_user: xiao_cp
* creat_date: 2025/8/27
* creat_time: 15:17
* description:
**/
public class JasyptUtil {
public static void main(String[] args) {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
// 设置加密密钥与配置中使用的密钥一致
config.setPassword("66668888"); // 替换为你的密钥
// 设置算法
config.setAlgorithm("PBEWithHMACSHA512AndAES_256");
config.setKeyObtentionIterations("1000");
config.setPoolSize("1");
config.setProviderName("SunJCE");
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");
config.setStringOutputType("base64");
encryptor.setConfig(config);
String plainText = "123456"; // 替换为你的数据库明文密码
String encryptedText = encryptor.encrypt(plainText);
System.out.println("Encrypted password: ENC(" + encryptedText + ")");
// 如需解密验证可使用下面一行
// System.out.println("Decrypted: " + encryptor.decrypt(encryptedText));
}
}

View File

@ -52,7 +52,8 @@ spring:
#url: jdbc:mysql://localhost:3306/cdsdb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
url: jdbc:mysql://101.42.2.210:3306/cdsdb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
password: c12321456
#password: c12321456
password: ENC(s/jC75JXj3bcSLJe3+9ML0JhKPEN6iz1U57Q0n4zei0fi/DCNagIX41osRheliDD)
# # 从库数据源
# slave:
# lazy: true
@ -105,7 +106,9 @@ spring.data:
# 数据库索引
database: 0
# redis 密码必须配置
password: 123456 #TongRDS->cfg.xml->Listen.Secure2或3需要密码(RedisPassword),其他不需要
#---TongRDS->cfg.xml->Listen.Secure2或3需要密码(RedisPassword),其他不需要
#password: 123456
password: ENC(6KdUNjp+dcCOa916uBD8QRPij7eGHovGlYLPN6bqCl3wjCctb3JMLi000jB6UFL7)
# 连接超时时间
timeout: 10s
# 是否开启ssl

View File

@ -81,7 +81,8 @@ spring:
# 设置总上传的文件大小
max-request-size: 100MB
#指定上传文件的临时目录,必须带,否则tongweb会报错
location: /data/upload_tmp
###注意,windows下tongweb此目录默认在domain空间下,需要手工创建,麒麟V10需要再验证!!!!!
location: /home/mps1/data/tmpdata
mvc:
# 设置静态资源路径 防止所有请求都去查静态资源
static-path-pattern: /static/**
@ -292,3 +293,17 @@ warm-flow:
- 255,205,23
## 已办理
- 157,255,0
jasypt:
encryptor:
# 加密算法3.0.x版本推荐使用更安全的算法
algorithm: PBEWithHMACSHA512AndAES_256
# 初始化向量生成器,使用 AES 等算法时需要
iv-generator-classname: org.jasypt.iv.RandomIvGenerator
# 盐生成器
salt-generator-classname: org.jasypt.salt.RandomSaltGenerator
# 输出类型
string-output-type: base64
#开发测试使用,上线部署时务必删除
password: 66668888

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="log.path" value="/log"/>
<property name="log.path" value="/home/mps1/logs"/>
<property name="console.log.pattern"
value="%cyan(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>

View File

@ -49,6 +49,12 @@
<version>8.0.9.03</version> &lt;!&ndash; 按实际版本调整 &ndash;&gt;
</dependency>-->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.5</version> <!-- 或更新版本,如 3.0.5 -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>