Showing posts with label Normal string Encrypt and Decrypt. Show all posts
Showing posts with label Normal string Encrypt and Decrypt. Show all posts

Monday, August 10, 2009

Normal string Encrypt and Decrypt

Encrypt and Decrypt string
======================

// Encrypt Method

private string EncryptString(string strSource)
{
Byte[] b = System.Text.ASCIIEncoding.ASCII.GetBytes(strSource);

string encryptedString = Convert.ToBase64String(b);

return encryptedString;
}


// Decrypt Method

private string DecryptString(string strSource)
{
Byte[] b = Convert.FromBase64String(strSource);

string decryptedString = System.Text.ASCIIEncoding.ASCII.GetString(b);

return decryptedString;
}