jasypt加密敏感信息

版权声明:一家之言,看完就忘了吧 https://blog.csdn.net/leisure_life/article/details/82781300

jasypt加密yml配置项


jdk:1.8
pom:

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

yml配置加解密串
在这里插入图片描述

获取加密密码
@Autowired
StringEncryptor stringEncryptor;

@Test
public void encryptPwd() {
	String pw = stringEncryptor.encrypt("yourpasswd");
	String us = stringEncryptor.encrypt("yourusername");
	System.out.println(pw);
	System.out.println(us);
}

这里原来是明文密码和明文用户名
在这里插入图片描述
测试连接

@Test
public void testDBConn(){
System.out.println(Driver.class);
}

猜你喜欢

转载自blog.csdn.net/leisure_life/article/details/82781300
今日推荐