为了保护数据库配置及数据安全,在一定的程度上控制开发人员流动导致敏感信息泄露
1.使用工具类生成秘钥以及对敏感信息进行加密
import com.baomidou.mybatisplus.core.toolkit.AES;
import org.junit.Test;
public class TestAES {
@Test
public void testAes() {
String randomKey = AES.generateRandomKey();String url = "jdbc:p6spy:mysql://127.0.0.1:3306/数据库名?useUnicode=true&characterEncoding=utf8";
// 数据库用户名 密码
String username = "root";
String password = "1234";String urlAES = AES.encrypt(url, randomKey);
String usernameAES = AES.encrypt(username, randomKey);
String passwordAES = AES.encrypt(password, randomKey);System.out.println("--mpw.key=" + randomKey);
System.out.println("mpw:" + urlAES);
System.out.println("mpw:" + usernameAES);
System.out.println("mpw:" + passwordAES);
}
}
运行后生成
2.配置加密信息
在启动类上加入秘钥