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