Android 应用ResponseText并将其作为inputstream

Android 应用ResponseText并将其作为inputstream,android,http,encryption,httpresponse,Android,Http,Encryption,Httpresponse,我只需要解密httpresponse的响应,响应是png图片,所以我做了: HttpPost httppost = new HttpPost(tileURLString); nameValuePairs.add(new BasicNameValuePair("x", String.valueOf(ValueX))); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 如果我收到答复 HttpResponse respon

我只需要解密httpresponse的响应,响应是png图片,所以我做了:

HttpPost httppost = new HttpPost(tileURLString);
nameValuePairs.add(new BasicNameValuePair("x", String.valueOf(ValueX)));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
如果我收到答复

HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
if (entity == null) {
    Log.i("Error","No content download");
}

InputStream in = entity.getContent();
这就是工作。但我需要将此输出作为字符串使用xor进行解密,所以我所做的只是:

String responseText = EntityUtils.toString(response.getEntity());
InputStream in = new ByteArrayInputStream(responseText.getBytes());
另外,这仍然不能解密正常的输入流,但无法工作。我在谷歌上搜索了一天。请帮帮我。如果这个工作,我将进入下一步解密。 提前谢谢

编辑:或者我使用这个方法 通过将InputStream转换为字符串

private String convertStreamToString(InputStream is) {

        BufferedReader reader = new BufferedReader(
                new InputStreamReader(is));
        StringBuilder sb = new StringBuilder();

        String line = null;
        try {
            while ((line = reader.readLine()) != null) {
                sb.append((line + "\n"));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return sb.toString();
    }
然后我用它转换回inputstream,但它也不起作用

    public InputStream convertStringToStream(String text)
            throws UnsupportedEncodingException {
        return new ByteArrayInputStream(text.getBytes("UTF-8"));
    }
改为

InputStream is = response.getEntity().getContent();

答案在本页中

感谢您的帮助。

如果我使用getEntity.getContent,在将响应转换为inputstream之前,我如何调整响应?
InputStream is = response.getEntity().getContent();