English 中文(简体)
采用对应办法,并将其作为投入
原标题:Apply ResponseText and put it as inputstream

我只需要从httpsresponse中解脱密码反应,而回答只是一纸空文:

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());

PS. this still not decrypt just normal inputstream but didn t work. I googled for a day. Help me please. if this work i ll go to next step (decrypt). Thanks in advance.

EDIT: or i use this method Convert InputStream to string by

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 + "
"));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return sb.toString();
    }

然后,即利用这一方法将反馈到投入流,但也做了一些工作。

    public InputStream convertStringToStream(String text)
            throws UnsupportedEncodingException {
        return new ByteArrayInputStream(text.getBytes("UTF-8"));
    }
最佳回答

答案载于本页。

铺设沥青阵列的平面阵列

感谢您的帮助。

问题回答
String responseText = EntityUtils.toString(response.getEntity());
InputStream in = new ByteArrayInputStream(responseText.getBytes());

更改

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




相关问题
Extend Contacts application on Android to provide encryption

I want to encrypt individual contacts stored by the Contacts application on Android based on user s preference. So, I am thinking I ll have to hook/extend the Contacts application before the it stores ...

Make md5 strong

Im making a website that will intergrate with game that only support md5 hashing metod (atm). Which ofc is not especially safe anymore. But how could i make it stronger? Should I just generate long ...

How to Pack/Encrypt/Unpack/Decrypt a bunch of files in Java?

I m essentially trying to do the following on a Java/JSP-driven web site: User supplies a password Password is used to build a strongly-encrypted archive file (zip, or anything else) containing a ...

Thread & Queue vs Serial performance

I though it ll be interesting to look at threads and queues, so I ve written 2 scripts, one will break a file up and encrypt each chunk in a thread, the other will do it serially. I m still very new ...

Convert PHP encryption code to C#

I m trying to convert this piece of code from PHP to C#. It s part of a Captive Portal. Could somebody explain what it does? $hexchal = pack ("H32", $challenge); if ($uamsecret) { $newchal = ...

Encryption: how to have 1 iv despite multiple fields

I ve been stuck trying to arrive at a best solution for this for a while. I know that an initialization vector has to be unique for each item being encrypted. So if I m encrypting an address and I ...

热门标签