springboot 集成 jasypt 配置文件加密

1. 导入maven包

<!-- https://mvnrepository.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot-starter -->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>

2.添加配置, 生成密文

  ①.在配置文件中新增配置

    jasypt.encryptor.password = jasyptTest

  ②.生成密文

    java -cp jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="123456" password=jasyptTest algorithm=PBEWithMD5AndDES

    

 

 

  ③. 用密文替换明文

    

 

 

 

3.在springboot启动Application.java加上注解

@EnableEncryptableProperties
posted @ 2020-10-22 09:35  knox大树  阅读(294)  评论(0编辑  收藏  举报