In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "tool class springboot how to encrypt the data in the configuration file", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "tool class springboot how to encrypt the data in the configuration file"!
First, introduce the configuration jasypt.encryptor.password that relies on implementation "com.github.ulisesbocchio:jasypt-spring-boot-starter:2.1.0". Second, add salt to the configuration file. Third, encrypt the information you want to encrypt.
The encrypted password string can be obtained by using the main method in this tool class.
Package utils;import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;import org.jasypt.encryption.pbe.StandardPBEByteEncryptor;import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;public class JasyptUtils {public static String encryptPwd (String password, String value) {PooledPBEStringEncryptor encryptOr = new PooledPBEStringEncryptor (); encryptOr.setConfig (cryptOr (password)); String result = encryptOr.encrypt (value); return result;} public static String decyptPwd (String password, String value) {PooledPBEStringEncryptor encryptOr = new PooledPBEStringEncryptor () EncryptOr.setConfig (cryptOr (password)); String result = encryptOr.decrypt (value); return result;} public static SimpleStringPBEConfig cryptOr (String password) {SimpleStringPBEConfig config = new SimpleStringPBEConfig (); config.setPassword (password); config.setAlgorithm (StandardPBEByteEncryptor.DEFAULT_ALGORITHM); config.setKeyObtentionIterations ("1000"); config.setPoolSize ("1"); config.setProviderName ("SunJCE"); config.setSaltGeneratorClassName ("org.jasypt.salt.RandomSaltGenerator") Config.setStringOutputType ("base64"); return config;} public static void main (String [] args) {/ / encrypted System.out.println (encryptPwd ("e9fbdb234534", "ZZB encrypted salesperson username 123 encryption #"); / / decryption / / System.out.println (decyptPwd ("e9fbdb2d3b21", "dcIXZ2hXkcuzbVwTjgOFoiYbeNtVUMtF9uzZZG7SQ0k=")) }} at this point, I believe you have a deeper understanding of "tool class springboot how to encrypt the data in the configuration file". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.