I am encrypting a text containing User Information in java using "AES" algorithm and appending it to the url,(which will be sent to the customer to have access to the application. And i am success in retrieving the encrypted text from the url in the client side (AngularJS) and send it back to the Server side(java) through a rest call to decrypt it and retrieve the corresponding Information.
But the problem i am facing is , since the encrypted text include "+" ,Java is treating it as a concatenation operator and is replacing it with a space changing the original encryption format before decryption
I tried encValue=encValue.replaceAll("\\+", "\\\\+")
for the
ecryptedText (encrypted URL parameter fetched in angularJS and when the same is passed to Java)
a6fPPqUwnkobdB7D8B53en+FlNcEt+Ehd4Ze6srqM/Q=
The result in java (Same Encrypted Value)
a6fPPqUwnkobdB7D8B53en\\ FlNcEt Ehd4Ze6srqM/Q=
I want the Encrypted text to retain its original structure
Thank you
But the problem i am facing is , since the encrypted text include "+" ,Java i treating it as a concatenation operator
That sounds very, very unlikely to me. It wouldn't explain why you're getting a space, either. Instead, this sounds like this is a URL-encoding issue... normally +
in a URL query parameter is used to encode space.
Basically, you should either use a URL-safe base64 encoding, or run the string through a URL-encoder before including it in the URL. So your query parameter should be
a6fPPqUwnkobdB7D8B53en%2BFlNcEt%2BEhd4Ze6srqM/Q=
See more on this question at Stackoverflow