Sudheer
Sudheer

Reputation: 151

Passing base64 encrypted string in the URL

I would like to know if I can pass a base64 encrypted , encoded string in the URL. Could you please advice on this !

Ex : https://localhost:1234/sampleapp/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=/abcded.pdf

When I wrote this in Spring , below is the controller I wrote :

 @Controller
 @RequestMapping("/sampleapp")
 public class ABC {

      @RequestMapping("/{encryptedText}/{fileName}")
      public bye[] streamContent(@PathVariable String encryptedText, @PathVariable String fileName){

      return ;
     }

 }  

Upvotes: 2

Views: 3821

Answers (1)

jbarrueta
jbarrueta

Reputation: 5175

Yes you can, as long as as the base64 string is URL Safe, this is replacing the non safe characters: '+', '/' and removing the padding character = of the Base64 string.

I'd recommend you this apache Apache commons-codec library that you can use to encode/decode Base64 URL Strings.

Hope this helps,

Jose Luis

Upvotes: 1

Related Questions