一、操作流程
-
在springboot项目中引入jasypt的staters
<dependency> <groupId>com.github.ulisesbocchio</groupId> <artifactId>jasypt-spring-boot-starter</artifactId> <version>2.1.1</version> </dependency>
-
springboot配置文件中添加如下配置:
# xxx为加密密钥 jasypt.encryptor.password=xxxx
-
编写单元测试,完成敏感数据加密
@RunWith(SpringRunner.class) @SpringBootTest(classes = JasyptApplication.class) public class JasyptApplicationTests { @Autowired private StringEncryptor encryptor; @Test public void contextLoads() {