Reader Level:

Public Key Encryption (RSA Method) for Encryption and Decryption in ASP.Net

By Brijesh Jalan on Aug 19 2010
In this article we will learn how use Public Key Encryption for Encryption and Decryption in ASP.Net
    • Like
    • Love It
    • Awesome
    • Interesting
    • It's Okay
    • Thumbs Down
  • 28.1k
  • 0

We already know about DES algorithm  method

The RSA Public Key Encryption is useful method for Encryption and Decryption .The Code behind the Method is mention below.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Security;
using System.Security.Cryptography;
using System.Text;
using System.IO; 

class Tester

    public static void Main()
        RSACryptoServiceProvider myRSAProvide = new RSACryptoServiceProvider();
        string strCrypt = null;
        byte[] bteCrypt = null;
        byte[] bteResult = null;
            strCrypt = "12345678";
            bteCrypt = Encoding.ASCII.GetBytes(strCrypt);
            bteResult = myRSAProvide.Encrypt(bteCrypt, false);
        catch (CryptographicException ex)
         string strResault = null;
        byte[] bteDecrypt = null;
            bteDecrypt = myRSAProvide.Decrypt(bteResult, false);
            strResault = Encoding.ASCII.GetString(bteDecrypt);
        catch (CryptographicException ex)

It is very simple pubic key encryption and decryption method.