SIGN UP MEMBER LOGIN:    
ARTICLE

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

Posted by Brijesh Jalan Articles | Cryptography C# August 18, 2010
In this article we will learn how use Public Key Encryption for Encryption and Decryption in ASP.Net
Reader Level:

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; 

public
class Tester

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

It is very simple pubic key encryption and decryption method.

Login to add your contents and source code to this article
share this article :
post comment
 

.NET Framework 4.5 is a very good looking wise and also User Friendly. .NET Framework Use With Visual Studio 2011.

Posted by Dileep Patel May 08, 2012
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor