赞
踩
1、导入依赖(自动配置)
<dependency> <groupId>com.github.ulisesbocchio</groupId> <artifactId>jasypt-spring-boot-starter</artifactId> <version>2.1.1</version> </dependency>
2、配置文件
jasypt: encryptor: password: ********* #加密秘钥
注意:每次生成的密码都不一样
需要加密的信息:
spring.datasource.password=ENC(************)
生成加密信息:
- @Test
- void textEncrpyt(){
- BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
- // 加密秘钥
- textEncryptor.setPassword("***********");
- String newString = textEncryptor.encrypt("root");
- System.out.println(newString);
- System.out.println(textEncryptor.decrypt(newString));
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。