简介:
Jasypt 是一个Java库,允许开发人员以很简单的方式添加基本加密功能,而无需深入研究加密原理。
添加maven依赖引入jasypt:
com.github.ulisesbocchio jasypt-spring-boot-starter 1.14 配置加密密码参数 jasypt.encryptor.password=root写了简单的测试用例
import lombok.extern.slf4j.Slf4j;
import org.jasypt.encryption.StringEncryptor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class ZcsjBaseApplicationTests {
@Autowired
private StringEncryptor encryptor;
@Test
public void getPass() {
String name = encryptor.encrypt("root");
String password = encryptor.encr