2

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.

  • I have encrypeted this using php function (base64_encode) , now i want to decode it in my android app please suggest – user1210848 Mar 01 '12 at 05:43
  • So it was **not encrypted**: it was **encoded as base64**. That is good :-) It means that this is an easier problem to solve. A useful search phrase might be "android base64" which returns this fine SO hit: [Is there a base-64 decoder and encoder for a string in Android?](http://stackoverflow.com/questions/4322182/base64-encoder-and-decoder) (And yes, there appears to be built-in support.) –  Mar 01 '12 at 06:20
  • If you are generating the data, the easiest way is to *not* base64-encode it... JSON Strings (and Strings in Java) can handle the full range of Unicode (handled via escapes and surrogate pairs as needed). –  Mar 01 '12 at 06:26

1 Answers1

0

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!

edthethird
  • 6,263
  • 2
  • 24
  • 34
  • I have encrypeted this using php function (base64_encode) , now i want to decode it in my android app please suggest – user1210848 Mar 01 '12 at 05:39
  • http://www.izhuk.com/painter/product/doc/Base64.java I didn't write this! Oh, and there is a big difference between encoding and encrypting! – edthethird Mar 01 '12 at 05:55