Thursday, August 21, 2008

Encrypt and Decrypt in C#

How to encrypt and decrypt text in C#?

I have simple way to do it.

Creat a form. 3 textbox and 2 command button.


private void button1_Click(object sender, EventArgs e)
{
textBox2.Text = Convert.ToBase64String(Encoding.Unicode.GetBytes(textBox1.Text));
}


private void button2_Click(object sender, EventArgs e)
{
textBox3.Text = Encoding.Unicode.GetString(Convert.FromBase64String(textBox2.Text));
}



1 comment:

navdeep saxena said...

good way..can u explain it