当前位置:网站首页>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);
}
}
边栏推荐
- Nlp-d62-nlp competition d31 & question brushing D15
- 【Cocos Creator 3.5.1】event. Use of getbutton()
- QListWidgetItem上附加widget
- 数据库-索引
- Netease cloud music params and encseckey parameter generation code
- MATLAB快速将影像的二维坐标转换为经纬度坐标
- Kubesphere cluster configuration NFS storage solution - favorite
- Assembly language - Wang Shuang Chapter 3 notes and experiments
- Two position relay hjws-9440
- leetcode299周赛记录
猜你喜欢

LeetCode-515. Find the maximum value in each tree row

树莓派4B上运行opcua协议DEMO接入kubeedge

JVM类加载机制

Multithreading basic Part3

LeetCode 0086.分隔链表
软件测试年终总结报告模板

IAR systems fully supports Centrino technology 9 series chips

Asp. Net core6 websocket simple case
Software testing year end summary report template

Run opcua protocol demo on raspberry pie 4B to access kubeedge
随机推荐
思维的技术:如何破解工作生活中的两难冲突?
【QT小点】QT下载链接
Nlp-d62-nlp competition d31 & question brushing D15
693. 交替位二进制数
爬虫学习5---反反爬之识别图片验证码(ddddocr和pytesseract实测效果)
多线程基础部分Part2
1317. convert an integer to the sum of two zero free integers
C# netcore中 配置帮助类IConfiguration
Opencv实现对象跟踪
Webrtc series - Nomination and ice of 7-ice supplement for network transmission_ Model
代码即数据
Spark's projection
mysql 查询时将状态改为相对应的文字
Leetcode99 week race record
Spark 之 Projection
美摄云服务方案:专为轻量化视频制作场景打造
Implementation of easyexcel's function of merging cells with the same content and dynamic title
js实现双向数据绑定
Using domain name forwarding mqtt protocol, pit avoidance Guide
cpu-z中如何查看内存的频率和内存插槽的个数?