Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure database encryption in SpringBoot file

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "SpringBoot how to configure the database encryption in the file", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to configure the SpringBoot file in the database encryption" article.

1. Import dependency

Com.github.ulisesbocchio jasypt-spring-boot-starter 2.1.2

two。 Find the location of jasypt-1.9.2.jar and open cmd

3. Enter the following command to execute

Java-cp jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input= "123456" password=sad124f1f1rf1fgt5 algorithm=PBEWithMD5AndDES

Input: clear text password

Password: salt to be added (can be set by yourself)

Algorithm: encryption algorithm, PBEWithMD5AndDES is used here

4. Configure in the application.yml file

Spring: datasource: driver-class-name: com.mysql.jdbc.Driver username: ENC (HPPHfpHVXzNf00SQLBrjug==) password: ENC (F8ckXFGTF6Wu8dQ51hoNBwalled =) url: jdbc:mysql://localhost:3306/foodie-shop-dev?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8jasypt: encryptor: password: sad124f1f1rf1fgt5

5. Configure the annotations in the startup class Application.java. The configuration is complete.

/ / configure database encryption comments @ EnableEncryptableProperties

6. Summary

In addition to the example of encrypting MySQL passwords, this method is more convenient when there are multiple passwords, Token, and so on in the configuration file.

In addition to supporting string keys, jasypt also supports key file keys, which is more secure.

When security requirements are high, you can also use the jasypt default PBEWITHHMACSHA512ANDAES_256 encryption algorithm, which requires JCE support.

7. problem

Problem description: encrypt using jasypt-spring-boot in Spring Boot, but prompt:

Description:

Failed to bind properties under 'spring.datasource.password' to java.lang.String:

Reason: Failed to bind properties under 'spring.datasource.password' to java.lang.String

Action:

Update your application's configuration

Solution:

3.0.2 changed the default encryption algorithm, the last resort is to reduce the version to 2.1.2

The above is about the content of this article on "how to configure database encryption in SpringBoot files". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report