当前位置:网站首页>Yaml file encryption
Yaml file encryption
2022-06-27 06:04:00 【Shirt boy】
Springboot and jasypt
Use jasypt encryption yaml Sensitive information in the file
1、 The required depend on
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
2、 Use in yaml Add the required key to the file
jasypt:
encryptor:
password: qwerty # secret key ( Customize )
algorithm: PBEWithMD5AndDES # encryption
3、 Key generation
java -cp jasypt-1.9.3.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="123456" password="qwerty" algorithm=PBEWithMD5AndDES
input: password ( Customize )
password: Custom key
algorithm: encryption
4、 Take steps 3 Command on jasypt Execute under dependency (cmd)

5、 Encryption method ( Take the account and password connecting to the database as an example )
@Autowired
private StringEncryptor stringEncryptor;
@Test
public void encryptPwd(){
// encryption
String username = stringEncryptor.encrypt("root");
System.out.println(" encryption username:"+username);
String decryptUserName = stringEncryptor.decrypt(username);
System.out.println(" Decrypt username"+decryptUserName);
String pwd = stringEncryptor.encrypt("123456");
System.out.println(" Encrypted password :"+pwd);
String decryptPwd = stringEncryptor.decrypt(pwd);
System.out.println(" Decrypt password "+decryptPwd);
}
6、 And then replace it according to the encrypted account password yaml The account number and password in the file are sufficient
username: ENC(+9yooqRfPCwdB2a+qMKZUA==)
password: ENC(vBoYnMFjRK8JUWTJo2XQJA==)
Be sure to add. ENC() Otherwise I can't recognize
It can also be in springboot Encryption key in the startup class of ( If you add it to the startup class, you don't need to write it in the configuration file , Just specify the encryption method )
public class DemoApplication {
public static void main(String[] args) {
System.setProperty("jasypt.encryptor.password", "qwerty");
SpringApplication.run(DemoApplication.class, args);
}
}
边栏推荐
猜你喜欢

JVM常用指令

Kubesphere cluster configuration NFS storage solution - favorite

Multithreading basic part2

yaml文件加密

30 SCM common problems and solutions!

Go日志-Uber开源库zap使用

Open the door small example to learn ten use case diagrams
软件测试年终总结报告模板

Openresty usage document

Using domain name forwarding mqtt protocol, pit avoidance Guide
随机推荐
多线程基础部分Part3
多线程基础部分Part2
How win 10 opens the environment variables window
QListWidget中的内容不显示
Senior [Software Test Engineer] learning route and necessary knowledge points
427- binary tree (617. merge binary tree, 700. search in binary search tree, 98. verify binary search tree, 530. minimum absolute difference of binary search tree)
Codeforces Round #802 (Div. 2)
JVM调优思路
IP网络通信的单播、组播和广播
多线程基础部分Part 1
汇编语言-王爽 第8章 数据处理的两个基本问题-笔记
vscode korofileheader 的配置
Functional continuous
多线程带来的的风险——线程安全
Netease cloud music params and encseckey parameter generation code
Unity中跨平台获取系统音量
【QT小点】实现看门狗功能,检测外部程序是否在运行
项目-h5列表跳转详情,实现后退不刷新,修改数据则刷新的功能(记录滚动条)
函数式 连续式
310. 最小高度树