TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Public Key Encryption and Decryption in ASP.NET
Pintoo Yadav
Apr 29
2015
Code
1.2
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
using
System.Collections;
using
System.Diagnostics;
using
System.Security;
using
System.Security.Cryptography;
using
System.IO;
namespace
Public_Key_Encryption
{
public
partial
class
Form1: Form
{
public
Form1()
{
InitializeComponent();
}
public
static
void
main()
{
RSACryptoServiceProvider myRSAProvide =
new
RSACryptoServiceProvider();
string
strCrypt =
null
;
byte
[] bteCrypt =
null
;
byte
[] bteResult =
null
;
try
{
strCrypt =
"golivecode.com"
;
bteCrypt = Encoding.ASCII.GetBytes(strCrypt);
bteResult = myRSAProvide.Encrypt(bteCrypt,
false
);
MessageBox.Show(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);
}
catch
(CryptographicException ex)
{
MessageBox.Show(ex.Message);
}
Console.ReadLine();
}
private
void
button1_Click(
object
sender, EventArgs e)
{
//Class1 obj = new Class1();
//obj.mess();
main();
}
}
}
ASP.NET
Public Key Encryption
Public Key Descryption