In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "SpringBoot project how to use application.yml files to configure database password encryption", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "SpringBoot project how to use application.yml files to configure database password encryption" bar!
For projects started with @ SpringBootApplication annotations, you only need to add maven dependencies
We use this jar package to encrypt and decrypt the information:
Write an encryption and decryption test class:
Package cn.linjk.ehome; import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;import org.jasypt.encryption.pbe.config.EnvironmentPBEConfig;import org.junit.Test; public class JasyptTest {@ Test public void testEncrypt () throws Exception {StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor (); EnvironmentPBEConfig config = new EnvironmentPBEConfig (); config.setAlgorithm ("PBEWithMD5AndDES"); / / encryption algorithm, which is the default config.setPassword ("test") / / encrypted key standardPBEStringEncryptor.setConfig (config); String plainText = "88888888"; String encryptedText = standardPBEStringEncryptor.encrypt (plainText); System.out.println (encryptedText);} @ Test public void testDe () throws Exception {StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor (); EnvironmentPBEConfig config = new EnvironmentPBEConfig (); config.setAlgorithm ("PBEWithMD5AndDES"); config.setPassword ("test"); standardPBEStringEncryptor.setConfig (config); String encryptedText = "ip10XNIEfAMTGQLdqt87XnLRsshu0rf0" String plainText = standardPBEStringEncryptor.decrypt (encryptedText); System.out.println (plainText);}}
Now that you have got the encrypted string, let's modify the configuration of application.yml:
We can just put the encryption string on ENC ({encryption string}).
You need to configure the secret key at startup
Add the secret key to the startup parameter
Thank you for your reading, the above is the "SpringBoot project how to use application.yml files to configure database password encryption" content, after the study of this article, I believe you on the SpringBoot project how to use application.yml files to configure database password encryption of this problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.