|
@@ -0,0 +1,42 @@
|
|
|
+package com.fdkankan.common.util;
|
|
|
+
|
|
|
+import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author ys
|
|
|
+ * @create 2021/9/22
|
|
|
+ * @desc Jasypt安全框架加密类工具包
|
|
|
+ **/
|
|
|
+public class EncryptDecrypt {
|
|
|
+ public static String algorithm = "PBEWithMD5AndDES";
|
|
|
+ public static String password = "4dage168...";
|
|
|
+
|
|
|
+ static StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor();
|
|
|
+ static {
|
|
|
+ standardPBEStringEncryptor.setAlgorithm(algorithm);
|
|
|
+ standardPBEStringEncryptor.setPassword(password);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ System.out.println(getEncrypt("JK20220120%JIK"));
|
|
|
+// System.out.println(getEncrypt("LTAI5tJZBJwP5qazE6b3b4Gr"));
|
|
|
+// System.out.println(getEncrypt("zSQCG0yyvRJISPokNZGhbhaAfh4hGX"));
|
|
|
+// System.out.println(getEncrypt("4dkankan524%40123*"));
|
|
|
+// System.out.println(getEncrypt("admin"));
|
|
|
+// System.out.println(getEncrypt("admin1231"));
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String getEncrypt(String value){
|
|
|
+ String password = standardPBEStringEncryptor.encrypt(value);
|
|
|
+ return "ENC(" +password +")";
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String getDecrypt(String value){
|
|
|
+ if(value.contains("ENC(")){
|
|
|
+ value = value.replace("ENC(","");
|
|
|
+ value = value.replace(")","");
|
|
|
+ }
|
|
|
+ return standardPBEStringEncryptor.decrypt(value);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|