-
引入依赖
com.github.ulisesbocchio jasypt-spring-boot-starter 3.0.2 -
定义密钥,并可以将密钥设置为参数或者在配置文件中写明
jasypt.encryptor.password=CodeSheep
-Djasypt.encryptor.password=
-
使用测试类生成密码的密文
junit junit test @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest public class TestControllerTest { @Autowired private StringEncryptor encryptor; @Test public void insert() { String password = "xxxx"; System.out.println(encryptor.encrypt(password)); } }



