I just need to decrypt response from httpresponse by the response is png picture so i did:
HttpPost httppost = new HttpPost(tileURLString);
nameValuePairs.add(new BasicNameValuePair("x", String.valueOf(ValueX)));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
and if I get response by
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
if (entity == null) {
Log.i("Error","No content download");
}
InputStream in = entity.getContent();
this is work. but i need to get this output as string to decrypt by use xor so all i did is:
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 + "\n"));
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
Then i use this to convert back to inputstream but it also didn’t work.
public InputStream convertStringToStream(String text)
throws UnsupportedEncodingException {
return new ByteArrayInputStream(text.getBytes("UTF-8"));
}
Solved for answer is in this page
Android byte array to string to byte array
Thanks for your help.