1

I am encoding URL request parameters from string to Base64 string using encodeURIComponent() method and passing it to server. Server side in servlet filter i am decoding it from Base64 to string using java.util.Base64.

I am not converting all the requests(request parameters). If the URL contains json request parameters than only I am encoding the request parameter.

Here my problem is I want to check the request parameters is encoded or not.

Can any one suggest me any method is available to identify request parameter is encoded or not.

user3291914
  • 39
  • 1
  • 9

1 Answers1

2

You can use commons method Base64.isBase64(String base64).

It returns a boolean True/False if your string is base64 encoded/or not.

Pankaj Singhal
  • 15,283
  • 9
  • 47
  • 86
  • Wrong! `Tests a given String to see if it contains only valid characters within the Base64 alphabet. Currently the method treats whitespace as valid.` The following will prove my point `Base64.isBase64("NOT_BASE64"); //true` – Edito Jul 29 '22 at 17:31