.NET provides us with several algorithm implementations to perform encryption and decryption. Next you can see an easy way to make use of a certificate to encrypt / decrypt using the RSACryptoServiceProvider
The first thing we need to do is to create a test certificate, this can be done by using the tool makecert. Just open the VS 2005 command prompt and type the next line:
makecert -n CN=Test -pe -ss My -sr LocalMachine
The command above will create a certificate called “Test” and will install it in the “My” location (displayed as “Personal”) of the Local Computer, the -pe will mark the private key as exportable.
You can see the test certificate you have created following the next steps:
1. Run the Microsoft Management Console (MMC) snap-in utility by running the command mmc from a command prompt.
2. On the File menu, click Add/Remove Snap-in.
3. In the dialog box that displays, click Add.
4. Under Snap-in, double-click Certificates.
5. Click Computer account to access the LocalMachine store, and then click Next.
6. Click Finish.
7. Click the Certificates node, Personal, Certificates and et voila, your certificate is there.
Now let’s see how we can make use of the certificate.
The code to use the above methods is very simple: