Friday, September 12, 2008

{C#} Simple 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;
}

No comments:

Post a Comment