simple XOR encryption
CodeKeep C# Feed Giugno 17th, 2008
Description: a simple encryptor/decryptor
Link: http://www.codekeep.net/snippets/bf47b389-24ba-41c5-9b23-2f2ffb64d0c9.aspx
/// <summary>
/// Class to encrypt and decrypt the password
/// </summary>
public static class EncryptorDecryptor
{
public static int key = 3;
/// <summary>
/// Encrypts and decrypts a given string.
/// </summary>
/// <param name="textToEncrypt">The text to encrypt or decrypt.</param>
/// <returns></returns>
public static string EncryptDecrypt(string textToEncrypt)
{
StringBuilder inSb = new StringBuilder(textToEncrypt);
StringBuilder outSb = new StringBuilder(textToEncrypt.Length);
char c;
for (int i = 0; i < textToEncrypt.Length; i++)
{
c = inSb[i];
c = (char)(c ^ key);
outSb.Append(c);
}
return outSb.ToString();
}
}






