Search code examples
jqueryencryptionasp.net-mvc-4antixsslibrary

Query string Encryption in Jquery Ajax request MVC 4


While making POST request using Jquery Ajax for a controller's action,What would be the better to encrypt the URL in the POST request and decrypt at Controller action,without involving the SSL.

I came across ANtiXSS library,does it provide the one I need.

Regards, Qureshi


Solution

  • Start simple - you can't encrypt the URL, but you can encrypt the query string. I'd start with something simple like ?q=value1|value2|value3 and use a simple Base64 encoded value so that the query string becomes ?q=dmFsdWUxfHZhbHVlMnx2YWx1ZTM=. Then you can decode and parse out the values by splitting on a separator like the pipe "|".

    If that's not enough, then search on public/private key encryption. You can use a js library to encrypt client-side with the public key and decrypt server-side with the private key.