一、引入依赖
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
二、配置
# 算法
jasypt.encryptor.algorithm= PBEWithMD5AndDES
# 密码
jasypt.encryptor.password=password
三、使用
@Autowired
private final StringEncryptor encryptor;
@Test
void contextLoads() {
String text = "1";
String encryptText = encryptor.encrypt(text);
System.out.println("加密(ikaros):"+encryptText);
System.out.println("解密(ikaros):"+encryptor.decrypt(encryptText));
}
结果: