zengjiebin лет назад: 7
Родитель
Сommit
8603c4ad25

+ 14 - 22
app/src/main/java/com/sheep/gamegroup/model/api/BaseMessageConverter.java

@@ -4,9 +4,7 @@ import android.text.TextUtils;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.kfzs.appstore.utils.string.HexUtils;
 import com.sheep.gamegroup.model.entity.BaseMessage;
-import com.sheep.gamegroup.util.LogUtil;
 
 import java.io.IOException;
 import java.util.HashMap;
@@ -32,41 +30,35 @@ public class BaseMessageConverter implements Converter<ResponseBody, BaseMessage
 
     /**
      * 加密
-     * @param requestJson
+     *
+     * @param data
      * @return
      */
-    public static String encrypt(String requestJson){
-        try {
-            byte[] byteEncode = Kfzssafe.XByteEncode(requestJson.getBytes());
-            return HexUtils.bytes2HexStr(byteEncode);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return requestJson;
-        }
+    public static String encrypt(String data) {
+        return Kfzssafe.xEncodeS2S(data);
     }
 
     /**
      * 解密
-     * @param respenseJson
+     *
+     * @param data
      * @return
      */
-    public static String decrypt(String respenseJson){
-        if(TextUtils.isEmpty(respenseJson)){
-            Map<String,String> map = new HashMap<>();
+    public static String decrypt(String data) {
+        if (TextUtils.isEmpty(data)) {
+            Map<String, String> map = new HashMap<>();
             map.put("msg", "0-byte body");
             return JSON.toJSONString(map);
         }
-        if(respenseJson.startsWith("{")){
-            return respenseJson;
+        if (data.startsWith("{")) {
+            return data;
         }
         try {
-            byte[] bytes = HexUtils.hexStr2Bytes(respenseJson);
-            byte[] byteDecode = Kfzssafe.XByteDecode(bytes);
-            return new String(byteDecode);
+            return Kfzssafe.xDecodeS2S(data);
         } catch (Exception e) {
             e.printStackTrace();
-            Map<String,String> map = new HashMap<>();
-            map.put("msg",respenseJson);
+            Map<String, String> map = new HashMap<>();
+            map.put("msg", data);
             return JSON.toJSONString(map);
         }
     }