This is my JSON code. Note the title field is base64_encoded. I want to get this title field value.
{"item":{"id":"1","title":"ZGVtbyBkZXNjcmlwdGlvbiBkZW1vIGRlc2NyaXB0aW9uIA==","status":"1"}},
{"item":{"id":"4","title":"ZGVtbyBldmVudCBmb3IgZGVtbyBkZXNjcmlwdGlvbg==","status":"1"}}
{"item":{"id":"6","title":"ZGVtbyBkZXNjcmlwdGlvbiBkZW1vIGRlc2NyaXB0aW9uIA==","status":"1"}}
The title text is in base64 format (ZGVtbyBkZXNjcmlwdGlvbiBkZW1vIGRlc2NyaXB0aW9uIA==) but I would like to get it as normal text -- how can I do this easily?
Thanks.
unfortunately the entire point of encryption is to stop people from doing this...
If you are legally obtaining the encrypted data, try getting in touch with the server team or checking their documentation to find out how they encrypt and how you should decrypt.
There isn't a one size fits all solution for this problem. The answer is 100% dependent on how the String is encrypted in the first place.
good luck!
Related
I want to extrect the Nutrients section of a vegetable/fruit from the wikipedia and want to show it in my android app.
This is what i have got so far..
To extract the Nutrients section of the "Banana"
https://en.wikipedia.org/w/api.php?action=parse&page=banana&prop=wikitext§ion=23&format=json
But i don't know how to filter out this table(the table in the right hand side of the above picture) from the data i have got from the above link. Is it something that i have to figure out in my codes when parsing this data or i have to do something with the url?
Can anyone help me to do this?
Yeah, you'll have to do that yourself. You can use https://en.wikipedia.org/api/rest_v1/page/mobile-sections/Banana which is a little easier to use (OTOH it's more internally focused and so less stable) and does remove certain parts of the HTML, but you'd still have to deal with the table. Or you can try https://en.wikipedia.org/api/rest_v1/page/html/Banana which uses the next-generation HTML renderer and has more metadata in the HTML so it's maybe easier to transform, but you'd still have to do the transformation yourself.
I created an android test app with camera interface in which I want to save a text message and image file as one object. I am able to enter message, call the camera,take a picture and also populate the image in the image view on the app. Now I want to save them as one single record/object so that I can transfer it over network using protocol such as ftp. How to save image file and text together as one single file/object? Could someone please tell me how to do that. Thanks in advance.
There are lots of possibilities, and it depends to some extent on what will be consuming the file after it is transferred. You could, for instance, simply serialize the string and the image data using a DataOutputStream wrapped around a FileOutputStream. As a fancy version of that, you could define a class to contain the text and the image, have that class implement Serializable, and serialize it to a file. Alternatively, you could serialize the image data as a base-64 string and then put the text and the base-64 image data into an XML document or JSON string. Other approaches are also possible.
If you provide more details about what kind of process will consume this file after it has been transferred, perhaps we can provide more focused suggestions.
Thanks for reading this question. I am sure the experts on this site will be able to provide the help I need.
I am trying to write an app which allows users to edit the exif information of the photos on their Android Phone.
As a part of improved user experience, I want to apply data validation where ever possible.
For the Exif Tag - TAG_GPS_PROCESSING_METHOD I am not able to apply the validation correctly.
Here is the part of code that I have applied :
String strGPSProc = etGPSProc.getText().toString();
if(strGPSProc.equalsIgnoreCase("GPS") || strGPSProc.equalsIgnoreCase("CELLID") || strGPSProc.equalsIgnoreCase("WLAN") || strGPSProc.equalsIgnoreCase("MANUAL") ) {
returnValue = true;
}else {
returnValue=false;
showToast("Incorrect value for GPS Processing Method. Correct value options are GPS, CELLID, WLAN or MANUAL.");
etGPSProc.requestFocus();
}
This code checks if the value entered in the EditText meant for GPSProcessingMethod, has any one of the four prescribed value as described in the documentation of EXIF.
But when I try to save this using setAttribute() and saveAttributes() functions, a non catch-able exception appears in logcat.
Unsupported encoding for GPSProcessingMethod
I understand from Exif Documentation that values for GPSProcessingMethod needs to be stored with some header information.
I need some expert advise on how to implement this correctly, with out using any other 3rd part classes.
Accoridng to the Exif specification:
GPSProcessingMethod
A character string recording the name of the method used for location finding. The first byte indicates the character
code used (Table 6、Table 7), and this is followed by the name of the method. Since the Type is not ASCII, NULL
termination is not necessary
Atually, Table 6 lists the character codes as 8 byte sequences, so the above should probably read "The first bytes indicate...". Anyway, the character code designation for ASCII is defined as 41.H, 53.H, 43.H, 49.H, 49.H, 00.H, 00.H, 00.H., Unicode is (unsurprisingly) 55.H, 4E.H, 49.H, 43.H, 4F.H, 44.H, 45.H, 00.H. I guess these should be all you need.
Hope that helps.
EDIT:
Just discovered that ExifInterface.setAttribute() only supports String values... You could try encoding the value at the beginning of your string, but I doubt that would work. Sounds like the encoding should be handled by the setAttribute() or saveAttributes() method. Could it be a bug in the API? I had a look at the source code, but the actual writing of values is done by native code so I stopped digging further.
Hi Everyone,
I am fetching a text from my DB and before inserting the text into db i know that the encoding of text is ISO-8859-1 , but after fetching from db and before loading this text i am checking the encoding through this code
InputStreamReader is = new InputStreamReader(new ByteArrayInputStream(body.getBytes()));
is.getEncoding();
Log.v("encoding", ""+is.getEncoding());
// String body = fetched from db
and i am getting in the log for the encoding of the text is UTF-8. And this text is not getting loaded on the webview with this method :
mailView.loadDataWithBaseURL(null, body, "text/html", "UTF-8", null);
please suggest me a correct way to solve this problem.
This reply is terribly late, but I stumbled on the question via Google and so thought I'd answer.
As described in the JavaDoc, new InputStreamReader(InputStream) will create a reader with the system default (apparently UTF-8). is.getEncoding() is simply returning that default which may or may not match your stored data.
In general, it is a good idea to specify the encoding of your stream explicitly. The implication is that you need to store the encoding along with the content. You can use out of band knowledge (e.g., my application only uses ISO-8859-1) but this will be brittle in the event that you change your chosen encoding in the future.
Since the world isn't always a nice place, and strings get separated from their charsets, you might look into a charset detector. See http://userguide.icu-project.org/conversion/detection as an example.
All I want to do is to send a URL String into my RESTFUL web service with some kind of code like this
URL someURL= new URL("http://myWebService:port/service/"+CharSequence.getText());
Its all going well until I found error with space character in my URL. I found some solution about replacing the space character with %20 which is I already defined with something like this :
URL someURL= new URL("http://myWebService:port/service/"+CharSequence.getText().replace(" ", "%20"));
Everything, again, seems going well until i found that the replace(Char oldChara, Char newChara) function can only replace ONE space character, and not two.
For brief example when I send the CharSequence.getText() with values "We won" there will be no error, but when I change the values into "We won the battles" there will be an error issuing that there are some illegal character sent to my RESTFUL web service.
Any kind of answer will come up with my great thanks and big salute
~Regards~
Use replaceAll instead of replace.
Although, you should really be doing proper URL encoding. You can use URLEncoder.encode
for example.