How to Encrypt and Decrypt URL Parameters in ASP.NET MVC
ASP.NET MVC platform itself provides very powerful libraries to process certain task. Passing information using URL parameters is a common practice in web development whether you want to ass an ID information for certain data retrieval or any other information of sort, but, it is highly recommended to not to pass any sensitive information like password within the URL parameter to avoid any eternal breaches. It is however also recommended to encrypt URL parameters data information even if it is not sensitive to avoid any external intrusions.
Today, I shall be demonstrating encryption and decryption of URL parameters using with ASP.NET MVC web platform.
Prerequisites:
Following are some prerequisites before you proceed any further in this tutorial:
- Knowledge of ASP.NET MVC.
- Knowledge of HTML.
- Knowledge of JavaScript.
- Knowledge of Bootstrap.
- Knowledge of Jquery.
- Knowledge of C# Programming.
The running working solution source code is
being developed in Microsoft Visual Studio 2019 Professional.
Download Now!
Let's begin now.
1) In the first step, create a new ASP.NET MVC web project and name it "MvcUrlParamEncryptDecrypt".
2) To encrypt and decrypt the URL parameter, use below lines of code, know that below lines of code practice secure encryption and decryption mechanism for URL parameters i.e.
... // Encrypt URL Parameter. string encryptInfo = MvcSerializer.Serialize("My Data", SerializationMode.EncryptedAndSigned); ... // Decrypt URL Parameter. string decryptInfo = MvcSerializer.Deserialize(encryptInfo, SerializationMode.EncryptedAndSigned).ToString(); ...
3) The provided solution demonstrated the encryption and
decryption of the URL parameters in a form of a quick UI tool. You can
execute the example project and demonstrate the feature in detail.
First, ASP.NET MVC application web application is loaded i.e.
Second, provide target URL, URL parameter key, and URL parameter Value. Then click encrypt and you will see encrypted URL parameter value as shown below i.e.
Finally, to decrypt the URL Parameter value that you have just encrypted, simply click the decrypt and decrypted URL parameter will be shown as below i.e.
Conclusion
In this article, you will learn to encrypt and then decrypt the URL parameter value using ASP.NET MVC platform. You will also learn to use the provided example solution visual features to encrypt and decrypt the URL parameter value.
This comment has been removed by the author.
ReplyDelete