0

I am having a little problem with BasicTextEncryptor.

Strings results are encoded in BASE64 after encryption. In my case I want to encrypt a string, and send it through URL parameter to a servlet. Within the servlet I want to decrypt this parameter and get the original string. The problem is that sometimes the encrypted string contains some characters (like spaces) and in URL those are represented in other symbols (+ for example). In this case I can't decrypt that string anymore because it is not anymore the same one.

Can anyone give me a hint how to solve this? I am doing this to perform an email confirmation through servlet link, if anyone could suggest me another solution will be very appreciated.

Noah Martin
  • 1,708
  • 9
  • 35
  • 73

1 Answers1

0

At the end the problem was simpler that I thought: Java URL encoding of query string parameters

I just encoded the string like this:

String url = "http://example.com/query?q=" + URLEncoder.encode(MyString, "ISO-8859-1");

Then the string that I will take from servlet request will be decoded to the right string by default.

Community
  • 1
  • 1
Noah Martin
  • 1,708
  • 9
  • 35
  • 73