Runt
10 days ago a3dc9d5522d8a5f2ebc71c8f4b7cd7695a6812d3
libmvi/src/main/java/com/runt/open/mvi/retrofit/converter/DecryptGsonResponseBodyConverter.java
@@ -13,7 +13,6 @@
import com.runt.open.mvi.utils.GsonUtils;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -36,7 +35,7 @@
    private final TypeAdapter<T> adapter;
    private final Charset UTF_8 = Charset.forName("UTF-8");
    private final boolean transHump;//驼峰转换
    private final String ENCRYPT = "encrypt";
    private final String ENCRYPT = "body";
    public DecryptGsonResponseBodyConverter(Gson gson, TypeAdapter<T> adapter, boolean transHump) {
        this.gson = gson;
@@ -52,10 +51,10 @@
            response = decryptJsonStr(val);//解密
        } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
            e.printStackTrace();
            response = "{\"code\":412,\"message\":\""+"解密数据出错"+e.getMessage()+"\"}";
            response = "{\"code\":412,\"msg\":\""+"解密数据出错"+e.getMessage()+"\"}";
        } catch (JSONException e) {
            e.printStackTrace();
            response = "{\"code\":414,\"message\":\"非标准json\"}";
            response = "{\"code\":414,\"msg\":\"非标准json\"}";
        }catch (Exception e){
            e.printStackTrace();
            JsonReader jsonReader = gson.newJsonReader(value.charStream());
@@ -88,9 +87,7 @@
        if(TextUtils.isEmpty(body)){
        }else if(body.indexOf("{") == 0) {
            JSONObject json = new JSONObject(body);
            body = RSAUtils.decrypt(json.getString(ENCRYPT), RSAUtils.getPublicKey(RSAUtils.PUBLIC_KEY));//
            //Log.e("Converter", "decryptJsonStr body:" + body);
            body = RSAUtils.decryptVerify(body,ENCRYPT);
        }
        return transHump? GsonUtils.toHumpJson(body):body;
    }