0

I have below string that have some base64 sub string for example:

"Hello a867e4== How are you 33e42r=="

I want to decode "a867e4==" and "33e42r==" from base64,but other character not decode.how can i do this?

Pa Pi
  • 3
  • 2
  • 1
    Is the sentence always going to be the same? Meaning will it always be "Hello {base64} How are you {base64}"? – Jose Martinez Feb 29 '16 at 22:34
  • Unless the format is very predictable, you're in for a lot of ambiguity... as various english words, e.g. "test", are also a valid base64 encoded string with a totally different value. – FatalError Feb 29 '16 at 22:37
  • Please consider asking a more complete question. Paste what you have tried, what results you are getting, what results you were expecting, and take the time to make sure your grammar is acceptable. Thank you. – K.Nicholas Feb 29 '16 at 22:44

1 Answers1

1

Assuming the base64 substrings are separated by a space, we can use split() method to get the substrings first, as shown below:

String[] parts = string.split("\\s+");

Once that is done, we can iterate over each part and check whether it's base64 encoded, as explained in this SO answer.

Community
  • 1
  • 1
Darshan Mehta
  • 30,102
  • 11
  • 68
  • 102