Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Public Key Encryption and Decryption in ASP.NET
WhatsApp
Pintoo Yadav
Apr 29
2015
1.3
k
0
0
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
Up Next
Public Key Encryption and Decryption in ASP.NET