Create a utility class with shared members so that nobody can create an instance of it.
Use the AlgorithmName property to specify the name of the algorithm (DES, TripleDES, RijnDael, or RC2). It supports generating a new key by reading this key from the file specified directly into the key property of an algorithm instance, and encrypting and decrypting data. You must set the algorithm name appropriately and then generate a key if none exists already to use this class.
Call the EncryptData and DecryptData methods, which will call the ReadKey method for initializing the algorithm. Specify whether the key should be protected through the DPAPI by using the ProtectKey property. Generate encryption keys through the algorithm classes.
To learn more about Cryptography in the .NET Framework, click here
We will first need a few helper classes. I put them in MyCrypto.Utility:
Now that we have the helper classes, lets setup our asymmetric encryption page. Inside of your empty ASP.NET web application, create a new web form.
For this example, you will need 3 textboxes and 4 asp controls (buttons,linkButtons...) to handle our click_Event.
You can see the html here
- Declare a private string named KeyFileName
- import: MyCrypto.Utility, System.IO, and System.Web.Security