public static string Encrypt( string s, int key) ... { string result=""; for (int i = 0; i < s.Length; i++) ...{ result += Convert.ToInt32((int)s[i] ^ key).ToString("x").ToUpper(); } return result; } public static string Decrypt( string s, int key) ... { string result=""; for (int i = 0; i < s.Length; i+=2) ...{ int temp = 0; int myTempR = int.Parse("EA", System.Globalization.NumberStyles.HexNumber); temp= int.Parse(s.Substring(i,2),System.Globalization.NumberStyles.HexNumber)^key; result += Chr(temp); } return result; } public static string Chr( int asciiCode) ... { if (asciiCode >= 0 && asciiCode <= 255) ...{ System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding(); byte[] byteArray = new byte[] ...{ (byte)asciiCode }; string strCharacter = asciiEncoding.GetString(byteArray); return (strCharacter); } else ...{ throw new Exception("ASCII Code is not valid."); } }