he2802 2 سال پیش
والد
کامیت
9e44f9a18a

+ 27 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/ToolsUtils.java

@@ -531,6 +531,33 @@ public class ToolsUtils {
         return new String(decryptedByteArray, StandardCharsets.UTF_8);
     }
 
+    public static String encryptDesNew(String source, String pass) throws Exception {
+        byte[] rgbKey = pass.getBytes("UTF-8");
+        byte[] rgbIV = pass.getBytes("UTF-8");
+        Cipher cipher = Cipher.getInstance("DES");
+        SecretKeySpec keySpec = new SecretKeySpec(rgbKey, "DES");
+        IvParameterSpec ivSpec = new IvParameterSpec(rgbIV); cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec);
+        byte[] inputByteArray = source.getBytes("UTF-8");
+        byte[] encryptedByteArray = cipher.doFinal(inputByteArray);
+        return Base64.getEncoder().encodeToString(encryptedByteArray);
+    }
+
+    /**
 
+     Des解密
+     @param source 源字符串
+     @param pass 密钥,长度必须8位
+     @return 解密后的字符串 */
+    public static String decryptDesNew(String source, String pass) throws Exception {
+        byte[] rgbKey = pass.getBytes("UTF-8");
+        byte[] rgbIV = pass.getBytes("UTF-8");
+        Cipher cipher = Cipher.getInstance("DES");
+        SecretKeySpec keySpec = new SecretKeySpec(rgbKey, "DES");
+        IvParameterSpec ivSpec = new IvParameterSpec(rgbIV);
+        cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
+        byte[] inputByteArray = Base64.getDecoder().decode(source);
+        byte[] decryptedByteArray = cipher.doFinal(inputByteArray);
+        return new String(decryptedByteArray, "UTF-8");
+    }
 
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeUserServiceImpl.java

@@ -640,7 +640,7 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
             //     data ="Z4lUlc48qtBmZcg4tbNmt767KDeYhu6h+Xz8ySE5MqYSy3tF1/m2cTLtAQRlHV9X4JtXoCwapll/IiMVNyrOwsZD9Ujjf682";
             byte[] Keys = new byte[]{0x22, 0x34, 0x76, 0x58, (byte) 0x90, (byte) 0xAB, (byte) 0xAD, (byte) 0xBF};
             byte[] rgbKey = OFFICIALPUSH_TOKEN.substring(0, 8).getBytes("UTF-8");
-            pars = ToolsUtils.decryptDes(bo.getData(), Keys, rgbKey);
+            pars = ToolsUtils.decryptDesNew(bo.getData(), OFFICIALPUSH_TOKEN.substring(0, 8));
         } catch (Exception e) {
             throw new CustomException("解析错误");
         }