引入druid依賴
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.15</version>
</dependency>
工具類
package com.xzsoft.frame.util;
import com.alibaba.druid.filter.config.ConfigTools;
/**
* @author sc
* @version V1.0
* @createTime 2020/7/1 9:35
* @description druid加解密
*/
public class Demo {
public static void main(String[] args) throws Exception {
testEncrypt();
testDecrypt();
}
public static void testDecrypt() throws Exception {
//解密 1234
String word="Qc+lVOUSHDmrG3CWleTKQ05KnUce/7QFrsowits2sLUzO2idxdn4r3UXWaYmRNxSlX4H0gMMN89hLCt6WGyejg==";
String decryptword = ConfigTools.decrypt(word);
System.out.println(decryptword);
}
public static void testEncrypt() throws Exception {
//加密
String password ="1234";
String encryptword = ConfigTools.encrypt(password);
System.out.println(encryptword);
}
}