配置文件
jasypt:
encryptor:
password: uoj20@d03jd
ppm文件
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>
java代码
public static void main(String[] args) {
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
//加密所需的salt(盐)
textEncryptor.setPassword("uoj20@d03jd");
//要加密的数据(数据库的用户名或密码)
String username = textEncryptor.encrypt("SYSDBA");
String password = textEncryptor.encrypt("SYSDBA");
System.out.println("username:" + username);
System.out.println("password:" + password);
}
数据库链接配置
username: ENC(YBAe8er2Bx6408OsHW8Hrw==)
password: ENC(dAgcl967wxLGCVtQ456MTQ==)
这篇博客介绍了如何使用Jasypt库在Java应用程序中进行数据加密。通过配置文件展示了加密密码,并在代码段中展示了如何使用BasicTextEncryptor对用户名和密码进行加密。加密后的数据被用于数据库连接配置,确保了敏感信息的安全。
942

被折叠的 条评论
为什么被折叠?



