How To Do End To End Data Encryption & Decryption in Web Form

Data encryption & decryption in ASP.Net web form

Encryption is a process that involves translating your text, documents, images, videos, and other data into gibberish data that cannot be understood by any human or machine. It only becomes readable after decryption which translates the random gibberish data back to its original state. This method can only be performed by someone who knows the exact way to decrypt the data and it often involves a key. Encryption and decryption become very useful when dealing with web applications that are hosted on the client side. As such, the encryption process can help maintain the security of your user’s data.

There are several benefits of encryption and decryption using ASP.Net. These are:

  1. The encryption can be performed in an unlimited number of devices.
  2. It helps ensure the security of your data during remote work and enhances its overall integrity.
  3. A strong encryption key will prevent hacks and other attacks on your web application.
  4. Encryption will also prevent identity theft and help keep you anonymous online.

In this blog, our DEV IT engineers have explained the steps needed to perform encryption and decryption in ASP.Net web forms for your web applications. The steps in doing so are:

1.) First of all, we need the javascript files listed below for the Client side to encrypt the content.

  • System.debug.js
  • System.IO.debug.js
  • System.Text.debug.js
  • System.Convert.debug.js
  • System.BitConverter.debug.js
  • System.IO.BinaryReader.debug.js
  • System.BigInt.debug.js
  • System.Security.Cryptography.SHA1.debug.js
  • System.Security.Cryptography.debug.js
  • System.Security.Cryptography.RSA.debug.js

2.) Next, we’ll need the class mentioned below for server side decryption and other functionality.

3.) Next, you will need two hidden keys filed for public key and for salt string.

4.) Example of Public key and private key used for encryption and decryption

Public key:


Private Key :


5.) You can save this key to the table and every time the user logins, it will start a new session, and both of these keys will change and store to the table.

Below is the code that changes both keys every time a new login is performed and saves it with respect to the user.

6.) Assign Public Key and Salt Hidden Field variables

7.) How we encrypt the content at the client side.

8.) Here we decrypt that encrypted content at the server side.


By following the steps in the blog, you would have learnt the methods and benefits of encrypting and decrypting your data. Now, you can begin securing yourself and your users with an advanced level of data security in a dangerous world of hackers. If you encounter any issues during the process, then feel free to drop a comment below and we will be sure to get back to you.

The following two tabs change content below.

Dharmesh Chudasama

Sr. Software Developer (.Net) at DEV Information Technology Ltd
Dharmesh Chudasama holds an MCA Master of Computer Application degree in education and works as Sr software developer in .NET technology in DEV IT. Dharmesh has over 8.5 years extensive experience in developing .NET based application and expertise in Basic MVC, C, C#, .NET ,ASP.NET , XM. He is recognized as best leader and team player and skill to easily understand client complex requirements and put in simple manner. Dharmesh loves playing cricket and watching a movie and listening soft music.

Latest posts by Dharmesh Chudasama (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *